mirror of
https://github.com/amnezia-vpn/amnezia-client.git
synced 2026-10-13 21:33:09 +00:00
[GH-ISSUE #3073] AWG self-hosted: H1–H4 hardcoded to 1/2/3/4 (WireGuard defaults), and ranged H breaks the client in 3.1 mode #1421
Open
opened 2026-10-13 20:42:09 +00:00 by bsakaguchi
·
7 comments
No Branch/Tag specified
dev
feat/api-tests
feat/gateway-service-import-test
fix/serialize-log-record-writes-and-pin-log-date-format-locale
fix/libagw-review-fixes
feat/otp-login
fix/ios-xray-ipv6-leak
fix/macos-xray-ipv6-leak
feat/add-support-include-split-tunnel
fix/win-xray-app-split-tunneling
fix/bug-when-saving-after-canceling
fix/xray-reconnect-crash
fix/share-empty-config-on-ssh-timeout
fix/ssh-credentials-input
fix/updater-verify-signature
fix/async-ssh-threading
fix/xray-check-inet-and-liveness-monitor
fix/selfhosted-server-installations
feat/add-support-ikev2-macos
fix/icons-different-color-themes
feat/add_support_arm_windows
feat/add-deep-link
feat/fixed-push-notifications-on-VPN-connect-disconnect-2
feat/implement-QR-code-generation-and-scanning
feat/file-password-protection
feature/add-local-proxy
feat/add-support-split-tunnel-macos
feat/tests
fix/android-register-unacknowledged-purchase
fix/share_on_linux
mirroring-to-outside
feat_copy_docker_configs
feat/self-diagnostics-log
feat/amnezia-free-vless-switch
fix/conan_build_android_on_win
fix/linux-reconnect-dns-reliability
fix/windows-connection-stability
fix/linux-reconnect-refactoring
fix/ios-groupidentifier-order
feat/xray-subscription-link
fix/minor-fixes
fix/xray-config-inplace-edit
feat/amnezia-sdk-typed-api
feat/amnezia-sdk-integration
feat/force-update-native
refactor/marketplace-update-popup
feat/force-update
fix/valnurability_dev
chore-xcode-version
fix/empty-i1-i5
build_qt_6_10_1
master
feat/protocol-selection
fix/openvpn_install
feat/locations_change
feat/locations_change_rework
feature/local-proxy-integration
fix/filepicker_atv
fix_valnurability
fix/macos-ne-codesign-4.8.19.0
temp-branch-for-testing
fix/rebased_4_8_19_linux_fix_error
feat/proxy-storage-cache
fix/zeroed-params
fix/killswitch-blocknets-linux
update/translation_RU
fix/self_hosted_reinstall_error
feat/selfhosted-dns
fix/agp_version_up
feat/switch_to_alive_protocol
feat/support_multipeer
server_scripts_update
fix/extended-vless-configuration
chore/apple-ci-cd-macos-versions
feat/add-telemt
fix/android_keystore_read_error
feat/add-mtproxy
chore/bump-qt-version
fix/make_dbus_async
feature/dns
rebase/apple-tv-target-on-conan
fix/outbound_freedom_xray_with_dns_fix
feat/apk_support
feat/fallback-proxy
feat/apple-tv-target
fix/dns_reconnection_issue
feat/fixed-push-notifications-on-VPN-connect-disconnect
fix/linux-firewall
docker-regional-locks
appstore-review-popup
feat/storekit2
fix/uninstall-split-tunnelling-driver
revert-2376-chore/license-file
support_16kb_android
bump_version
feat_add_review_android
bugfix/translation-absence-on-subscription-key-page
feat/location-separation-by-region
bugfix/text-moving-when-resing-window
fix_backup
feature/add-purchase-android
bugfix/moved-text-while-resizing-window
bugfix/incorrect-killswitch-restore-from-backup
fix/backup-exclude-secondary-api-configs
feat/proxy-fields-for-dev-console
bugfix/ovpn-ios-fix
bugfix/linux-bundle-libraries
fix/xray-app-split-win
fix/upload-to-s3
chore/add-release-date-upload
feat_add_webview_support
feature/configuration-transfer-through-qr
feat/bot-key-unlink-device
fix/ad-link-lang-support
fix/qsecuresettings-with-android
feat/add-support-arm64-win
spanish-translations
fix/context-menu
feat/add-system-dns-support
fix/qt6-9-support
fix/qt6_9_support
bugfix/strict-killswitch-ui
android-7
chore/minor-bugfixes
feature/awg-net-fix-macos-wakeup
fixbug/ios18
bugfix/ios-ne-crash
fix/linux-tray-quit-button
cryptpad-support
bugfix/disable-linux-killswitch
fix/minor-ui-fixes
feature/setup-guid-tun2socks
feature/linux-ipsec
feature/ipsec-linux
refactoring/server-config-in-classes
feature/macos-ipsec
fix/ui-fixes-after-merge-with-d20ed4a
chore/focus_control_after_qt_6.9_migration
feature/integrate-xray-as-a-library
maxos-awg-fix
feature/add-new-awg-docker-image
chore/update-3rd-prebuild
feature/test-news
fix/api-conf-files
bugfix/split-tunneling-with-api-config
bugfix/ios-awg-new-fields
feature/special-handshake-2
feat/xray-api-support
fix/desktop-entry
bugfix/shadowsocks-cipher-setting-not-changing
feature/update-tap
bugfix/openvpn_import_fix
feature/ability-to-change-port-after-installing-xray
bugfix/strict-mode-ovpn
bugfix/win-ipv6-ovpn
bugfix/subnet-adress-setting
exception-podman-docker
bugfix/fix-listviewtype-scrolling
bugfix/win-disabled-ipv6
bugfix/win-ipv6-disabled-ovpn
feature/killswitch-strict-mode
feature/awg-network-check
feature/empty-split-tunneling-list
feature/support-info
chore/update-go-version
checking-Linux-version
update_server_scripts
bugfix/button-selection-easy-setup-page
feature/old-api-proxy
patch/user-checking
fix/correcting-version
support-podman
support_podman
user-checking-patch
feature/check-docker-version
feature/allowed-dns-list
without_lsof
chore/error-body
Update-amneziavpn_ru_RU
shiroow-patch-8
shiroow-patch-7
shiroow-patch-6
shiroow-patch-5
shiroow-patch-4
shiroow-patch-3
shiroow-patch-2
shiroow-patch-1
check_sudo_permissions
feature/euphoria
add_next_octet_to_ip_settings
bugfix/mobile-controllers-init
euphoria
bugfix/android-crush
feature/macox-network-extension
bugfix/pre-release-hotfixes
bugfix/ipsec-pfs
chore/ios-site-links
checking_sudo_permissions
feature/android-tv
improve_navigation_cpp
bugfix/linux-firewall-install
fixbug/wireguard-handshake-time
ReadmeRu_full
feature/xray-user-management
feature/subscription-end-date
chore/clang-format
feature/ru-in-readme
chore/increased-api-timeout
chore/deploy-workflow
bugfix/services-list-scroll
wheel_group_suppor
chore/bump-xcode-version
fixbug/mac-network-extension
feature/android-gpb
feature/page-home-drawer-country-selection
checking-sudo-users
bugfix/service-info-from-response
fixbug/build-macos-ne-2
android-qt-6.7.3
fixbug/build-macos-ne
bugfix/wg-windows-log-folder
feature/psk-key-api-request
bugfix/user-management-qml-warnings
fix/macos-network-extension
fixbug/macos-NE-build
bugfix/fixed-isDevEnv-initialization
bugfix/revert-ios-ovpn
feature/tun2socksSrv
fix/disable_singleapp
feature/awg-wg-name-resolving
feature/disable-dhcp
bugfix/allowed-ips-old-configs
feature/goodbyedpi
feature/add-exception-log
refactoring/remove-ipv6-from-default-routes
refactoring/singleapplication-submodule
macos-dirty-build
test/gateway
Update-amneziavpn_fa_IR.ts
bugfix/ipsec-win
fix/xray-custom-port
improve-tab-navigation
test-win-11
feature/android-tv-remote-control-support
KsZnak-patch-1
feature/awg-wg-qr
bugfix/fix-loopback-splittunel
fix/setup_host_firewall
feature/android-xray
feature/openvpn-pass
feature/connection-string
fix/clickable-errors
bugfix/api_1100_fix
feature/graphview
testsvg
feature/update-win-awg
feature/open-as-amnezia
feature/update-mozilla-upstream
bugfix/qr-code-cutting
feature/native-wg-psk
test/awg-centos
bugfix/hide_error
feature/add-uninstaller-checkbox
bugfix/cancel-button-on-install-page
bugfix/anchors-page-home-warning
awg-udptlspipe
button-focus-fix
revert-677-fix/logger
bugfix/Revert_PR_596
bugfix/allowed-ips-api-configs
bugfix/on-escape-pressed
feature/auto-scroll-for-server-selection-list
fix/ui-fixes
translations/update_fa_IR.ts
feature/new-awg-docker-container
bugfix/awg_ipv6_fix
feature/tab-navigation
fix/username-no-autocapitalization
sure
refactoring/servers-model-cleanup
feature/wg-mtu-setup-ios
3rd_adaptation_to_diff_OS
sudo_not_found
test/docker-ce
bugfix/double_clear_server_from_amnezia
fix/android
client/3rd-prebuilt
revert-559-KsZnak-translation-ru-ex
KsZnak-translation-ru-ex
KsZnak-br1
KsZnak-text-change
feature/api-awg
feature/error-code-output
feature/win_x32_builds
text/debug-output
feature/ovpn3-desktop-cli
bugfix/secureqsettings-deadlock
refactoring/change-settings-when-connected
files_check
ArchLinux-support
second_adaptation_to_diff_os
sudo
refactoring/android-build
adaptation_to_different_os
feature/online_installer_for_v4
update_to_r2
bugfix/return-after-installation
feature/custom_drawer_component
bugfix/split-tunneling
bugfix/existing-awg-container
revert-370-feature/custom_drawer_component
bugfix/adapted_awg_questiondrawer
bugfix/updated_drawer_height_pageserverdata
bugfix/translated_new_source_strings_to_chinese
feature/split-tunneling-config
feature/accessibility-support
branch_connectivity_change_fix
feature/ikev2_android
android_ss_transport
bugfix/macos_fixes
feature/nextcloud-support
feature/macos_network_extension
android_pt_transport_source
feature/ios-openvpn3-pluggable-transport-Cloak
bugfix/cloak_for_desktops_fix
arm-build-macos
fix-macos-build-brew
bugfix/ios-build-openvpnadapter-from-source
feature/download-native-wireguard-config-on-connect
feature/v2ray-container
bugfix/dpkg-busy-checking-stuck
feature/online-installer
dev-killswitch
dev-netadapters
5.0.3.0
5.0.2.1
5.0.2.0
5.0.1.5
5.0.0.5
5.0.0.2
4.8.21.0
4.8.19.0
4.8.18.0
4.8.17.0
4.8.16.0
4.8.15.4
4.8.15.0
4.8.14.5
4.8.14.1
4.8.12.9
4.8.12.8
4.8.12.7
4.8.12.6
4.8.11.4
4.8.11.3
4.8.11.2
4.8.11.1
4.8.11.0
4.8.10.0
4.8.9.2
4.8.9.1
4.8.9.0
4.8.8.3
4.8.8.2
4.8.8.1
4.8.7.2
4.8.7.1
4.8.7.0
4.8.6.0
4.8.5.0
4.8.4.5
4.8.4.4
4.8.4.3
4.8.4.2
4.8.4.1
4.8.4.0
4.8.3.2
4.8.3.1
4.8.2.3
4.8.1.9
4.8.1.0
4.8.0.5
4.7.0.0
4.6.0.3
4.6.0.1
4.5.3.0
4.5.0.0
4.4.0.0
4.3.0.0
4.2.1.0
4.2.0.1
4.1.2.0_cloak_pt_experimental
4.1.0.1
4.0.8
3.1.0
3.0.8
3.0.7
3.0.5
2.1.2
2.1.0
2.0.10
2.0.9
2.0.8
2.0.7
2.0.6
2.0.5
2.0.1
2.0
1.9.1
1.9
1.8
1.7
1.6
1.5
1.4
1.3
1.2
1.1
1.0
No labels
pull-request
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".
No due date set.
Dependencies
No dependencies set.
Reference
amnezia-vpn/amnezia-client#1421
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @leonidorlov-hash on GitHub (Aug 27, 2026).
Original GitHub issue: https://github.com/amnezia-vpn/amnezia-client/issues/3073
When installing AmneziaWG on a self-hosted server via the app, H1–H4 are always set to 1/2/3/4 — see
client/core/utils/constants/protocolConstants.h(defaultInitPacketMagicHeader[] = "1"etc.) used byclient/core/installers/awgInstaller.cpp, and again inimportController.cpp. These are the standard WireGuard message-type values, so header obfuscation is effectively disabled: a DPI sees plain WireGuard packet types at offset 0.Per the amneziawg-go docs, H1–H4 also accept ranges (
x-y), which is the AWG 2.0+ way to randomize headers per packet. But if the server uses ranged H together with AWG 3.1 parameters (HeaderProtectionKey,RandomTrailers, etc.), the client connects yet throughput collapses to <1 Mbit/s and the log is flooded withReceived packet with invalid mac1(hundreds per second). Ranged H with plain AWG 2.0 (no 3.1 keys) works fine in the same client.Tests I ran on the same server:
Questions:
Related: #2942 (3.0 parameters silently dropped on import).
Environment: AmneziaVPN desktop (Windows), server
amneziavpn/amneziawg-go:latestin userspace mode (no kernel module on host).@Advisorrry commented on GitHub (Aug 28, 2026):
это вы правильно подметили, жаль раньше не наткнулся. У меня амнезия поднимается через исходники, а не через self-hosted. Долго пришлось думать в чем была проблема низкой скорости. Странно, что никакой документации еще не было выложено
@Vitalik93 commented on GitHub (Aug 28, 2026):
Мне кажется в версии 3.1 рандомизацию H1-H4 отключили не просто так. Вместо диапазона ее заменили на Header Protection. Просто мое предположение.
@Autolocsia commented on GitHub (Aug 28, 2026):
Лично я откатился на 2.0 потому что версия 3.1 сырая и неработоспособная, даже на бета версию не тянет, альфа
@leonidorlov-hash commented on GitHub (Aug 28, 2026):
Update: the question raised here («why are H1–H4 hardcoded to 1,2,3,4?») now has a well-documented answer, and it turns out the hardcode is accidentally the safe option.
Two independent deep-dives filed in the last few days analyse the packet classifier in both implementations:
RandomTrailers = on, the relaxed size check (>=instead of==) admits ordinary transport packets into the H1/H2/H3 handshake branches. If the 4 bytes at the branch offset fall inside the configured range, the packet dies at CheckMAC1 («Received packet with invalid mac1») — silently, with zero counters moving. Per-branch loss probability ≈ range width / 2³². Wide auto-generated ranges (e.g. 50–350M values wide) cost 16–25% of all traffic; measured 75% loss at 50% width.04 00 00 00type field, key_idx, or the counter's high bytes), even a narrow range can match ~100% of packets. So «just narrow the ranges» is not a reliable mitigation.This is exactly the failure mode we hit and reported here: a 3.1 install with wide auto-generated H1–H4 ranges showed thousands of
Received packet with invalid mac1and throughput below 1 Mbit/s; replacing the ranges with fixed values instantly restored full speed.Consequence for generators (panels, install scripts): fixed single-value H1–H4 — whether hardcoded 1,2,3,4 or a random u32 per install — are currently the only safe shape, since width-1 ranges make the loss probability ~2⁻³² per branch and the chance of landing on the constant band negligible. Ranged H1–H4 combined with
RandomTrailers = on(which the client's own defaults ship) are effectively broken on both implementations until the classifier is fixed upstream.So the practical ask stands: until #186 / #226 are resolved, please either document that H1–H4 must be single values when
RandomTrailersis on, or have the client tooling reject ranged values in that combination — otherwise third-party generators keep producing configs that lose most of their traffic with no visible error anywhere.@Vitalik93 commented on GitHub (Aug 29, 2026):
Статью про AmneziaWG кстати обновили. Там в частности написано, почему H1-H4 стоят на 1-4. https://docs.amnezia.org/ru/documentation/amnezia-wg
@leonidorlov-hash commented on GitHub (Aug 30, 2026):
Closing the loop on this one — the case is now solved, and the answer is «it's documented behaviour, not a bug».
The official AmneziaWG documentation was updated (https://docs.amnezia.org/ru/documentation/amnezia-wg/) and now states explicitly:
And in the parameter table: H1 is disabled at value 1, H2 at 2, etc.
So the client's hardcoded 1,2,3,4 is the documented «compatibility mode»: when
HeaderProtectionKeyis set, custom headers are intentionally off and message-type hiding is done by Header Protection (ChaCha20 keyed with the random per-server key). Config uniqueness between servers comes from the HP key, junk sizes and port — not from H values.This also aligns with the classifier research in amnezia-vpn/amneziawg-go#186 / amnezia-vpn/amneziawg-linux-kernel-module#226: ranged H1–H4 combined with
RandomTrailers = oncause silent transport packet loss, while width-1 values (1,2,3,4 or any fixed value) are safe. The docs now even carry a related warning («при использовании RandomTrailers рекомендуется задавать одинаковые значения для S1–S4... пакеты могут быть интерпретированы неверно»).For anyone generating configs (panels, scripts): with AWG 3.1 + HeaderProtectionKey, emit H1–H4 = 1,2,3,4. Don't use ranged H with RandomTrailers on until the classifier issues are fixed upstream.
Closing as answered — thanks to the authors of #186/#226 for the deep-dives that made the whole picture clear.
@HeisLuka commented on GitHub (Sep 9, 2026):
I re-checked this against current
dev, the current AmneziaWG documentation, and currentmasterof bothamneziawg-goand the Linux kernel module.I think this issue now has two very different parts.
1.
H1 = 1, H2 = 2, H3 = 3, H4 = 4is no longer a bugThe original question about the hardcoded values has effectively been answered by the current protocol design.
Current
AwgInstallerstill deliberately initializes:and also generates a
HeaderProtectionKey.The current AmneziaWG documentation now explicitly describes these as the compatibility values for Header Protection.
With:
the old custom-message-header mechanism is disabled and the packet type is instead hidden by Header Protection.
So I would not change the installer to generate random fixed H values merely to make every self-hosted configuration different.
When Header Protection is enabled, the current
1/2/3/4defaults are intentional.The issue reporter already reached the same conclusion in the later discussion.
2. The ranged-H + RandomTrailers failure is still real
The underlying classifier problem reported in:
is still present in current source.
The Go implementation currently classifies in this order:
and for the first three branches, when
RandomTrailersis enabled, the size condition becomes approximately:Only after those branches does it try the transport classifier.
Therefore a sufficiently long ordinary transport packet can enter one of the handshake H-range tests.
If its four bytes happen to fall inside that configured H range, it can be classified as a handshake candidate and subsequently fail authentication instead of reaching the transport branch.
The current Linux kernel module has the same ordering and equivalent relaxed size conditions.
So the observed:
has a real source-level explanation.
This part is not resolved merely because
1/2/3/4became the recommended default.3. Current Amnezia client can still create the problematic configuration
This is the client-side part that I think remains actionable.
In current:
all four server H fields explicitly use:
so values such as:
are accepted.
The same page also exposes:
independently.
Therefore the UI permits:
with no compatibility warning.
Given the current upstream classifier behavior, this is a configuration shape capable of causing severe silent packet loss.
4. The existing H1-H4 validation does not actually validate range overlap
There is another deterministic validation bug here.
Before saving, the QML calls:
and rejects the configuration with:
But the underlying implementation is:
This checks string equality, not numerical range intersection.
So:
is rejected.
But:
is accepted.
Those ranges overlap from:
despite the current AmneziaWG documentation explicitly requiring H1-H4 ranges not to overlap.
So the useful invariant is not:
It is:
after parsing each single value as a width-1 range.
5. Cross-field validation is needed
There are two separate levels of validation.
Basic H-range validity
For every H field:
and all four resulting ranges must be disjoint.
Known-bad runtime combinations
While the upstream classifier bug remains present, the client should at minimum detect:
and either:
or present a very explicit warning.
For AWG 3.1 with Header Protection, the strongest safe UX is probably to guide users toward:
which is also the documented compatibility configuration.
I would avoid silently rewriting imported third-party configurations, though. A loud validation error/warning preserves user intent while making the compatibility problem visible.
6. Imported/stored configurations preserve these values as strings
The current model serializes and restores:
independently.
AwgConfiguratoralso copies H values directly from the generated/native config map intoAwgClientConfig.There is no central semantic validator establishing:
when the configuration enters the model.
So putting the check only in one QML page would still leave:
able to bypass it.
This should ideally be a model/protocol-level validation invariant, with the UI only displaying the resulting diagnostic.
Suggested regression cases
Expected:
This is the documented compatibility mode.
Expected:
as today.
Expected:
Currently this passes the string-equality check.
Expected:
because both include
200.Expected:
subject to the RandomTrailers compatibility rule.
Expected:
when valid for the selected protocol features.
RandomTrailers = on.Until the upstream classifier issue is fixed:
Expected:
rather than successful import followed by unexplained packet loss.
Classification
So I would narrow the original issue rather than treat the whole report as one bug:
Resolved/by design:
Still confirmed upstream:
Still confirmed in current Amnezia client:
and:
The safest default is already present. The remaining client bug is that users and third-party configurations can leave that safe envelope without the client detecting a configuration known to be ambiguous/broken.