Skip to main content

AmneziaWG

AmneziaWG is a fork of WireGuard-Go. It inherits the architectural simplicity and high performance of the original implementation, while removing the identifiable network signatures that make WireGuard easy for Deep Packet Inspection (DPI) systems to detect.

Version 1.5 took obfuscation to the next level: traffic could be disguised as common UDP protocols, such as QUIC, DNS, and others.

Version 2.0 extends this approach to full "mimicry": traffic becomes less recognizable to DPI not only when the connection starts, but also while data is being transmitted, thanks to constantly changing headers and packet sizes. This reduces the likelihood of VPN traffic being identified by characteristic patterns and makes heuristic analysis more difficult.

Version 3.1 was developed in response to widespread blocking in Russia in June and July 2026, which showed that masking individual traffic characteristics was no longer sufficient. The new version makes statistical analysis of connections more difficult by varying packet sizes, packet sequences, timing intervals, and some protocol metadata. This makes different sessions less repetitive and reduces the likelihood of AmneziaWG being identified through a combination of characteristics.

The predecessor of AmneziaWG, WireGuard, has established itself as a fast and reliable VPN protocol thanks to its compact codebase and high efficiency. However, its fixed packet headers and predictable packet sizes create an easily recognizable signature. DPI systems can identify such packets and immediately terminate the connection, which is a serious problem in countries with internet censorship.

AmneziaWG 1.5 addressed this issue through multi-level obfuscation at the transport layer: it modified packet headers, randomized handshake message sizes, and allowed traffic to be disguised as popular UDP protocols.

AmneziaWG 2.0 further strengthens obfuscation: it uses dynamic ranges for headers instead of static values, adds random bytes to special WireGuard packets, and extends the signature CPS packets before the handshake to mimic UDP protocols more convincingly. At the same time, the fundamental cryptographic core of WireGuard remains unchanged, preserving its performance and security.

AmneziaWG 3.1 protects traffic from detection not only by individual headers or packet sizes, but also by the behavior of the connection as a whole: new mechanisms hide some protocol metadata, add random padding to the content, change the timings of service events, and reduce the repeatability of packet flow. This version also makes WireGuard cookie behavior less recognizable, since it can be used during active probing as an additional fingerprint. This makes protocol detection by DPI systems and behavioral analysis more difficult, while keeping the WireGuard cryptographic core unchanged.


Key Advantages

  • DPI resistance - dynamic headers from specified ranges and randomized packet sizes.
  • Protocol masking - imitation of QUIC, DNS, SIP, and other UDP protocols.
  • High performance - runs as a Linux kernel module, while encryption uses the same single-pass AEAD ChaCha20-Poly1305 algorithm with SIMD optimization as WireGuard.
  • Energy efficiency - Go code runs in user space without heavy cryptography, making it suitable for mobile devices and routers.
  • Cross-platform support - support for all major operating systems.
  • UDP transport - all traffic is transmitted over UDP, which helps bypass blocking and reduces latency.
  • Ease of configuration - it is enough to specify the signature of the masking protocol; the remaining parameters are filled in automatically.
  • Backward compatibility - when masking parameters are disabled, the AmneziaWG configuration is fully compatible with WireGuard.

How It Works

The following are the main mechanisms that AmneziaWG 3.1 uses to change the characteristic patterns of WireGuard traffic and make it less recognizable to DPI.

  1. Dynamic headers for all packet types (H1-H4)

    During tunnel initialization, the library generates a set of random values from specified ranges, which are applied to each of the four WireGuard packet formats: Init, Response, Cookie, and Data. These values:

    • replace predictable WireGuard packet identifiers;
    • shift the offsets of Version/Type fields;
    • change reserved bits.

    For each outgoing packet, a random value is selected from the range; on reception, any value from the range is accepted. This makes the header unpredictable even for the same packet type.

    Important: H1-H4 ranges must not overlap.

    As a result, two different clients do not have matching headers, making a universal DPI rule impossible to write.

  2. Packet length randomization (S1-S4)

    In WireGuard, the Init packet is exactly 148 bytes, Response is 92 bytes, Cookie is 64 bytes, and Data has a variable payload size. AmneziaWG adds pseudorandom prefixes S1, S2, S3, and S4 (from 0 to 32/64 bytes):

    len(init) = 148 + S1
    len(resp) = 92 + S2
    len(cookie) = 64 + S3
    len(data) = payload + S4

    These prefixes hide the standard sizes of WireGuard messages and shift service fields deeper into the packet.

  3. Obfuscation packets I1-I5 (Signature Chain) and CPS (Custom Protocol Signature)

    Before the handshake (every 120 seconds), the client can send up to five different UDP packets fully described by the user in CPS format. The main element, I1, contains a hex snapshot of a real protocol, such as QUIC Initial handshake, which can also be randomized. The remaining I2-I5 packets increase entropy through a counter, timestamp, and random data.

    We call this format CPS - Custom Protocol Signature:

    i{n} = <tag1><tag2><tag3>...<tagN>

    Tag types

    TagFormatDescriptionConstraintsExample
    b<b hex_data>Static bytes for protocol imitationArbitrary length<b 0xf6ab3267fa>
    t<t>Unix timestamp (32-bit, network byte order)Unique within the sequenceUnix time
    r<r length>Cryptographically secure random byteslength ≤ 1000<r 20>
    rc<rc N>Random ASCII letters [A-Za-z] for imitating text protocolsN ≤ 1000<rc 10> -> "aBcDeFgHiJ"
    rd<rd N>Random decimal digits [0-9] for imitating numeric fieldsN ≤ 1000<rd 5> -> "13654"

    Example of a CPS packet:

    i1 = <b 0xd100000001><rc 8><t><r 50>

    The example above only demonstrates CPS syntax and is not an example of a signature. Do not use it as the value of the I1-I5 parameters.

    Packets I1-I5 are sent independently, in order from I1 to I5. For each configured parameter, the corresponding packet is sent. If one parameter is missing, the other configured packets are still sent. If none of the I1-I5 parameters are set, CPS packets are not sent.

  4. Junk-train (Jc)

    Immediately after the I-packet chain, Jc pseudorandom packets are sent with lengths from Jmin to Jmax. They blur the beginning of the session in time and size, making handshake detection even more difficult.

  5. Header Protection

    AmneziaWG 3.1 introduces Header Protection. This mechanism additionally hides unencrypted service parts of WireGuard packets that can be used as static protocol fingerprints.

    ChaCha20 is used for obfuscation. The nonce is taken from the first 12 bytes of the corresponding S1-S4 prefix, and the key is specified by the HeaderProtectionKey parameter.

    Note: when using Header Protection, it is recommended to leave H1-H4 at the standard compatibility values: H1 = 1, H2 = 2, H3 = 3, H4 = 4. In this mode, the custom header mechanism is disabled, and the message type is hidden by Header Protection.

    Header Protection is applied to the following parts of packets after Sx:

    Init     - 148 bytes
    Response - 92 bytes
    Cookie - 64 bytes
    Data - 16 bytes

    To use Header Protection, S1-S4 values must be at least 12 bytes, and HeaderProtectionKey must be set.

  6. Content Padding

    WireGuard pads transport data to a size that is a multiple of 16 bytes. This repeating pattern can be used in statistical analysis.

    The ContentPaddingAddition parameter adds a random number of bytes from a specified range to transport packets. The padding uses the available space up to the internal MTU and does not exceed it.

  7. Custom Timings

    WireGuard uses fixed intervals for re-handshake, keepalive, timeout, and repeated connection attempts. In AmneziaWG 3.1, these values can be specified as ranges.

    When the protocol needs to set one of these timers, it selects a random value from the specified range. This makes the behavior of different sessions less repetitive over time.

  8. Random Trailers

    Even when S1-S4 are used, packet sequences can remain similar in size. For example, the Handshake Initiation + Handshake Response sequence can repeat in a fairly stable way.

    RandomTrailers adds a random number of bytes to the end of packets. For handshake packets, random data is added; for transport packets, zeroes are added to the end of the internal IP packet.

    The trailer size is selected with the current UDP window in mind. This window changes during data exchange between the two sides, preventing violations of the MTU of both sides.

    When using RandomTrailers, it is recommended to set the same values for S1, S2, S3, and S4. This reduces the risk of incorrect packet type detection. This is because packets have random sizes and may be interpreted incorrectly.

  9. Disabling Cookie Reply

    In WireGuard, the Cookie Reply mechanism is used to protect against DoS attacks: instead of a normal Handshake Response, the receiving side can send a special Handshake Cookie Reply message.

    Under normal conditions, this mechanism works well, but in censorship environments cookie behavior can be used during active probing and become a separate protocol fingerprint.

    The DisableCookies parameter disables only the sending of Handshake Cookie Reply messages. Incoming cookie messages and other cookie-related mechanisms continue to work the same way as in the original WireGuard implementation.


Configuration Parameters

range<uint16> and range<uint32> are numeric ranges. They can be specified as a-b or as a single fixed value a. uint16 accepts values from 0 to 65,535; uint32 accepts values from 0 to 4,294,967,295.

ParameterType / valuePurpose
I1-I5CPS-descriptionObfuscation packets before handshake
S1-S4uint16Random prefixes for Init, Response, Cookie, and Data
Jcuint16Number of junk packets
Jmin, Jmaxuint16Minimum and maximum junk packet size
H1-H4range<uint32>Custom message type identifiers
HeaderProtectionKey32-byte keyKey for Header Protection
ContentPaddingAdditionrange<uint16>Random addition to the transport payload
RekeyAfterTimerange<uint16>Interval before re-handshake
RekeyTimeoutrange<uint16>Handshake timeout
RejectAfterTimerange<uint16>Interval after which the connection initiates a new handshake if no data is received
KeepaliveTimeoutrange<uint16>Interval before sending keepalive
MaxHandshakeAttemptsrange<uint16>Maximum number of handshake retries
RandomTrailerson / offAdds random trailers to packets
DisableCookieson / offDisables sending Cookie Reply

If a mechanism's value is 0, off, or the 0-0 range, the mechanism is disabled and standard WireGuard behavior is used.

For H1-H4, a separate compatibility rule applies:

  • H1 is disabled when set to 1
  • H2 is disabled when set to 2
  • H3 is disabled when set to 3
  • H4 is disabled when set to 4

Security

AmneziaWG 3.1 does not change the cryptographic core of WireGuard. Key exchange, user data encryption, and the basic security model remain the same as in WireGuard: Noise_IK, Curve25519, and AEAD ChaCha20-Poly1305.

The new AmneziaWG mechanisms operate at the transport obfuscation layer. They hide or change the external characteristics of the connection: message types, packet sizes, service packet sequences, and timings. This helps make protocol detection by DPI systems more difficult, but does not replace the main WireGuard encryption.

Header Protection uses ChaCha20 to additionally hide service parts of the packet. This mechanism is not intended to protect the user payload; it reduces the number of stable characteristics that can be used to identify the protocol.

Since the cryptographic foundation of WireGuard remains unchanged, existing WireGuard security analyses remain applicable to AmneziaWG. The new parameters should be considered mechanisms for masking and DPI resistance, not a separate cryptographic scheme.


Additional Resources

Native AmneziaWG Clients

AmneziaWG configuration files can also be used in specialized clients if the client supports the protocol version for which the file was released:

Contact the chat for help if something does not work