mirror of
https://github.com/amnezia-vpn/amneziawg-tools.git
synced 2026-10-13 21:34:42 +00:00
[GH-ISSUE #44] H1-H4 values displayed incorrectly by awg showconf when using AWG 1.x kernel module #19
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
amnezia-vpn/amneziawg-tools#19
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 @wvolkov on GitHub (Apr 3, 2026).
Original GitHub issue: https://github.com/amnezia-vpn/amneziawg-tools/issues/44
Originally assigned to: @ygurov on GitHub.
H1-H4 values displayed incorrectly by
awg showconfwhen using AWG 1.x kernel moduleSummary
awg showconfdisplays H1-H4 values as raw uint32 decimal numbers instead of the original string values when communicating with AWG 1.x kernel module. This causes tools like WGDashboard to read the wrong values and write them back to .conf, corrupting the configuration.Environment
master)Steps to Reproduce
Expected Output
Actual Output
Root Cause Analysis
The problem is in
ipc-linux.h, in theGET_MAGIC_HEADERmacro (line ~38):When the kernel module reports version < 2 (AWG 1.x), the tools:
put_magic_header_attr): parse the string "112", convert to uint32 = 112, send via netlink asNLA_U32GET_MAGIC_HEADER): receive uint32 from kernel, convert back to string withsnprintf("%u", ...)This works correctly when the kernel stores and returns the numeric value 112.
However, the kernel module appears to store the H value as raw bytes of the ASCII string. So when tools send uint32 = 112 (0x00000070), the kernel stores 0x00000070. But when reading back, the kernel returns 0x00323131 (which is the bytes
'1','1','2','\0'in little-endian) = 3289393 decimal.This can be verified:
Values that fit in a single byte (1, 5) or happen to be large enough to not be visually affected (1000, 65536) appear to work correctly, masking the bug for many configurations.
Impact
This is a data corruption bug when used with management tools:
H1 = 112in .confawg-quick upapplies it correctly — tunnel worksawg showconf→ seesH1 = 3289393H1 = 3289393back to .confawg-quick upsends 3289393 as uint32 → kernel now has a different valueThis also affects
awg-quick save, which callsawg showconfinternally — so even without a dashboard, anyawg-quick saveorawg-quick down(withSaveConfig = true) will corrupt H values in the .conf file.Suggested Fix
In
GET_MAGIC_HEADER, when reading uint32 from AWG 1.x kernel, check if the bytes represent an ASCII string and decode accordingly. Or, ensure thatput_magic_header_attrandGET_MAGIC_HEADERuse a consistent encoding (both numeric or both string).Alternatively,
showconf.calready usesprintf("H1 = %s\n", device->init_packet_magic_header)which would work correctly ifmagic_headercontained the original string — the conversion inGET_MAGIC_HEADERviasnprintf("%u", ...)is what breaks it.