Skip to content

[Bug] AmneziaWG connection closes with ERR_CONNECTION_CLOSED when parsing config with specific hex parameters #3033

Description

@music61

Verify steps

  • I have read the documentation and understand the meaning of all the configuration items I have written, rather than just piling up seemingly useful options or default values.
  • I have carefully reviewed the documentation and have not resolved the issue.
  • I have searched the Issue Tracker for the issue I want to raise and did not find it.
  • I am a non-Chinese user.
  • I have tested with the latest Alpha branch version, and the issue still persists.
  • I have provided the server and client configuration files and processes that can reproduce the issue locally, rather than a sanitized complex client configuration file.
  • I provided the simplest configuration that can be used to reproduce the errors in my report, rather than relying on remote servers or piling on a lot of unnecessary configurations for reproduction.
  • I have provided complete logs, rather than just the parts I think are useful out of confidence in my own intelligence.
  • I have directly reproduced the error using the Mihomo command-line program, rather than using other tools or scripts.

Operating System

Android, Windows

System Version

All supported OS (Platform independent core bug)

Mihomo Version

v1.18.1 / v1.19.2 and latest Alpha branch

Configuration File

proxies:
  - name: "AmneziaWG-Node"
    type: wireguard
    server: 0.0.0.0
    port: 51820
    ip: 10.0.0.2
    public-key: "SERVER_PUBLIC_KEY_PLACEHOLDER="
    private-key: "CLIENT_PRIVATE_KEY_PLACEHOLDER="
    allowed-ips: ['0.0.0.0/0']
    udp: true
    mtu: 1280
    amnezia-wg-option:
      jc: 4
      jmin: 40
      jmax: 70
      h1: 1
      h2: 2
      h3: 3
      h4: 4
      i1: "0xc70000000108ce1bf31eec7d93360000449e227e4596ed7f75c4d35ce31880b4133107c822c6355b51f0d7c1bba96d5c210a48aca01885fed0871cfc37d59137d73b506dc013bb4a13c060ca5b04b7ae215af71e37d6e8ff1db235f9fe0c25cb8b492471054a7c8d0d6077d430d07f6e87a8699287f6e69f54263c7334a8e144a29851429bf2e350e519445172d36953e96085110ce1fb641e5efad42c0feb4711ece959b72cc4d6f3c1e83251adb572b921534f6ac4b10927167f41fe50040a75acef62f45bded67c0b45b9d655ce374589cad6f568b8475b2e8921ff98628f86ff2eb5bcce6f3ddb7dc89e37c5b5e78ddc8d93a58896e530b5f9f1448ab3b7a1d1f24a63bf981634f6183a21af310ffa52e9ddf5521561760288669de01a5f2f1a4f922e68d0592026bbe4329b654d4f5d6ace4f6a23b8560b720a5350691c0037b10acfac9726add44e7d3e880ee6f3b0d6429ff33655c297fee786bb5ac032e48d2062cd45e305e6d8d8b82bfbf0fdbc5ec09943d1ad02b0b5868ac4b24bb10255196be883562c35a713002014016b8cc5224768b3d330016cf8ed9300fe6bf39b4b19b3667cddc6e7c7ebe4437a58862606a2a66bd4184b09ab9d2cd3d3faed4d2ab71dd821422a9540c4c5fa2a9b2e6693d411a22854a8e541ed930796521f03a54254074bc4c5bca152a1723260e7d70a24d49720acc544b41359cfc252385bda7de7d05878ac0ea0343c77715e145160e6562161dfe2024846dfda3ce99068817a2418e66e4f37dea40a21251c8a034f83145071d93baadf050ca0f95dc9ce2338fb082d64fbc8faba905cec66e65c0e1f9b003c32c943381282d4ab09bef9b6813ff3ff5118623d2617867e25f0601df583c3ac51bc6303f79e68d8f8de4b8363ec9c7728b3ec5fcd5274edfca2a42f2727aa223c557afb33f5bea4f64aeb252c0150ed734d4d8eccb257824e8e090f65029a3a042a51e5cc8767408ae07d55da8507e4d009ae72c47ddb138df3cab6cc023df2532f88fb5a4c4bd917fafde0f3134be09231c389c70bc55cb95a779615e8e0a76a2b4d943aabfde0e394c985c0cb0376930f92c5b6998ef49ff4a13652b787503f55c4e3d8eebd6e1bc6db3a6d405d8405bd7a8db7cefc64d16e0d105a468f3d33d29e5744a24c4ac43ce0eb1bf6b559aed520b91108cda2de6e2c4f14bc4f4dc58712580e07d217c8cca1aaf7ac04bab3e7b1008b966f1ed4fba3fd93a0a9d3a27127e7aa587fbcc60d548300146bdc126982a58ff5342fc41a43f83a3d2722a26645bc961894e339b953e78ab395ff2fb854247ad06d446cc2944a"

Description

There is a critical bug in Mihomo's WireGuard/AmneziaWG core parser when trying to handle premium or self-hosted configurations using the new AmneziaWG parameters (amnezia-wg-option).

While the exact same configuration runs flawlessly in the official AmneziaWG native client, importing it into Mihomo results in a complete transport failure across all platforms, and any network request immediately ends with ERR_CONNECTION_CLOSED.

Steps to Reproduce

  1. Generate an AmneziaWG native client configuration with long I1 initialization hex strings.
  2. Convert it to Mihomo YAML syntax according to the simplified format documentation.
  3. Start the Mihomo core, enable TUN mode, and select this node.
  4. Try to perform an HTTP request (or a proxy check through the dashboard panel).

Expected Behavior

The core should properly handle obfuscated handshakes, successfully authenticate the handshake, and route traffic just like the native AmneziaWG implementations do on all operating systems.

Actual Behavior

The proxy panel shows Test Failed on any proxy test, and the core instantly aborts connection attempts (ERR_CONNECTION_CLOSED), implying that the packet payload structure for the i1 signature parameter gets malformed during parsing or compilation by the internal Go implementation. Please investigate how amnezia-wg-option maps these parameters to the network layer.

Reproduction Steps

  1. Create a WireGuard configuration with AmneziaWG obfuscation parameters (specifically containing a long hex string for 'i1').
  2. Convert it into Mihomo YAML proxy format following the official documentation.
  3. Import the config into any Mihomo client (e.g., Clash Mi / Karing), enable TUN mode.
  4. Try to connect or trigger a proxy test. The proxy immediately fails with ERR_CONNECTION_CLOSED.

Logs

The dashboard UI fails to render text logs properly due to the core transport loop instantly dropping the session with ERR_CONNECTION_CLOSED. The control panel simply reports 'Test failed' in the Network Info block immediately after the connection attempt.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions