[GH-ISSUE #6277] [Feature]: HWID is not supported Clash/Mihomo clients #4260

Closed
opened 2026-10-31 20:38:21 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @LORD07Sson on GitHub (Aug 21, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6277

Describe the bug

When HWID is enabled for a VLESS inbound, connections through Clash/Mihomo clients do not work 404...

The same VLESS configuration works correctly when HWID is disabled. This appears to be a compatibility issue between the HWID authentication/identification mechanism and Clash/Mihomo clients.

Clash and Mihomo do not appear to support the HWID parameter required by the inbound configuration, which makes the generated configuration unusable with these clients when HWID is enabled.

How to reproduce the problem

1.Create a VLESS inbound
2.Enable HWID for the inbound/client
3.Generate or import the configuration into a Clash/Mihomo-based client
4.Connect using the generated configuration
5.Observe that the connection does not work
6.Disable HWID for the same inbound/client
7.Try connecting again with Clash/Mihomo
8.The connection works normally

Expected behavior

When generating a subscription or configuration for Clash/Mihomo, x-ui should automatically handle the lack of HWID support. If the selected client does not support HWID, the subscription should be generated without the HWID parameter instead of producing an unusable configuration.

Ideally, there should also be an option to manually add or generate a subscription without HWID for clients that do not support it, while keeping HWID enabled for clients that support it

Actual behavior

When HWID is enabled, the generated configuration cannot be used successfully with Clash/Mihomo. Disabling HWID fixes the problem

Relevant logs


Screenshots

No response

3x-ui version

Dev

Xray-core version

26.7.28

How did you install 3x-ui?

install.sh script

Operating system

Ubuntu 24

Which parts of the panel are affected?

Subscription (share links / Clash / JSON)

Browser (only if it is a UI bug)

No response

Is the panel behind a reverse proxy or CDN?

No — direct access

Before submitting

  • I searched existing issues and this bug has not been reported.
  • I am running the latest released version of 3x-ui (or have verified the bug still exists on it).
  • This bug report is written in English.
  • I have redacted any sensitive data (tokens, real domains, client UUIDs).
Originally created by @LORD07Sson on GitHub (Aug 21, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6277 ### Describe the bug When HWID is enabled for a VLESS inbound, connections through Clash/Mihomo clients do not work 404... The same VLESS configuration works correctly when HWID is disabled. This appears to be a compatibility issue between the HWID authentication/identification mechanism and Clash/Mihomo clients. Clash and Mihomo do not appear to support the HWID parameter required by the inbound configuration, which makes the generated configuration unusable with these clients when HWID is enabled. ### How to reproduce the problem 1.Create a VLESS inbound 2.Enable HWID for the inbound/client 3.Generate or import the configuration into a Clash/Mihomo-based client 4.Connect using the generated configuration 5.Observe that the connection does not work 6.Disable HWID for the same inbound/client 7.Try connecting again with Clash/Mihomo 8.The connection works normally ### Expected behavior When generating a subscription or configuration for Clash/Mihomo, x-ui should automatically handle the lack of HWID support. If the selected client does not support HWID, the subscription should be generated without the HWID parameter instead of producing an unusable configuration. Ideally, there should also be an option to manually add or generate a subscription without HWID for clients that do not support it, while keeping HWID enabled for clients that support it ### Actual behavior When HWID is enabled, the generated configuration cannot be used successfully with Clash/Mihomo. Disabling HWID fixes the problem ### Relevant logs ```shell ``` ### Screenshots _No response_ ### 3x-ui version Dev ### Xray-core version 26.7.28 ### How did you install 3x-ui? install.sh script ### Operating system Ubuntu 24 ### Which parts of the panel are affected? Subscription (share links / Clash / JSON) ### Browser (only if it is a UI bug) _No response_ ### Is the panel behind a reverse proxy or CDN? No — direct access ### Before submitting - [x] I searched [existing issues](../issues?q=is%3Aissue) and this bug has not been reported. - [x] I am running the latest released version of 3x-ui (or have verified the bug still exists on it). - [x] This bug report is written in English. - [x] I have redacted any sensitive data (tokens, real domains, client UUIDs).
bsakaguchi 2026-10-31 20:38:21 +07:00
Author
Owner

@github-actions[bot] commented on GitHub (Aug 21, 2026):

The 404 is the HWID gate working as written, not a broken subscription: as soon as a client's HWID Limit is greater than 0, the panel refuses every machine-readable subscription body for a request that does not carry an X-HWID header, and Clash/Mihomo never send that header. So your observation is right, and your conclusion ("Clash/Mihomo do not support the HWID parameter") is right too — it just isn't a defect in the panel, it is the gate's designed behaviour.

What the code does

internal/sub/controller.go:615-633 — the gate reads the device id straight off the request headers:

func (a *SUBController) enforceHwid(c *gin.Context) bool {
	result, err := a.clientService.EnforceHwidForSubID(c.Param("subid"), service.HwidRequest{
		Hwid:        c.GetHeader("X-HWID"),
		...
	if !result.Allowed {
		c.Status(http.StatusNotFound)
		return false
	}

internal/web/service/client_hwid.go:100-103 — a missing or too-short X-HWID is denied (Allowed stays false), with minHwidLength = 6 at client_hwid.go:34:

	if len(req.Hwid) < minHwidLength {
		res.NotSupported = true
		return res, nil
	}

The gate runs on all three body routes — raw /sub/ (controller.go:390), /json/ (controller.go:714) and /clash/ (controller.go:765) — and that is pinned by a test, which is why this reads as intended rather than accidental: TestSubscriptionHwidGateAcrossBodyRoutes (internal/sub/hwid_controller_test.go:87-98) asserts 404 plus X-Hwid-Not-Supported: true for /sub/, /json/ and /clash/ when no X-HWID header is sent. TestSubscriptionHwidGateSkipsHtmlInfoPage (hwid_controller_test.go:124-134) pins the opposite for the browser page — which explains why the same link still opens fine in a browser while the client gets a 404.

You can confirm it on your own server in two commands (the second one registers a device, see the cleanup note below):

curl -s -o /dev/null -D - -H 'User-Agent: mihomo/1.19' "https://YOUR_HOST/sub/YOUR_SUBID"
curl -s -o /dev/null -D - -H 'User-Agent: mihomo/1.19' -H 'X-HWID: test-device-123' "https://YOUR_HOST/sub/YOUR_SUBID"

The first returns 404 with X-Hwid-Active: true and X-Hwid-Not-Supported: true; the second returns 200. Anything registered that way can be removed with the HWID Devices button next to the HWID Limit field in the client edit dialog.

What you can do today

  1. Leave HWID Limit at 0 for clients that use Clash/Mihomo — 0 short-circuits the gate before any header is looked at (client_hwid.go:92-95: if limit <= 0 { res.Allowed = true; return res, nil }), and the limit is stored per client (LimitHwid, internal/database/model/model.go:924), so a mixed fleet is already possible.
  2. One caveat on that: the effective limit is MAX(limit_hwid) over all enabled clients sharing the same sub_id (client_hwid.go:70-77). If your Clash user shares a subId with an HWID-limited client, the limit still applies to them. Give them their own subId.
  3. Keep HWID Limit only for clients whose app sends X-HWID (the feature's own tests use Happ/1.0 and Karing/2.0 user agents — an indication of the intended client set, not a compatibility list I can verify from this repository).

The rest of your report — "generate the subscription without HWID for clients that don't support it" — is a feature request, not a bug, so I have relabelled the issue enhancement (removing bug) and left it open for a maintainer to decide, rather than closing it. Two notes for whoever picks it up: auto-detecting "unsupported" clients would have to key off the User-Agent, which any device can set, so it would weaken the gate it bypasses (my reading, not something the source states); and the HWID Limit tooltip currently says only "Maximum registered devices for subscription requests. 0 = unlimited." (internal/web/translation/en-US.json:743) — it never warns that a non-zero value makes the link unusable in clients that don't send X-HWID, which is what made this look like a bug.

Verdict: Not a bug (expected behaviour)
Severity: N/A
Confidence: High
Root cause: No defect. SUBController.enforceHwid (internal/sub/controller.go:615-633) denies with 404 whenever ClientService.EnforceHwidForSubID returns Allowed=false, and client_hwid.go:100-103 returns exactly that for a request whose X-HWID header is shorter than minHwidLength = 6 (client_hwid.go:34) — i.e. any client that sends no such header, including Clash/Mihomo. Triggering condition: a client with limitHwid > 0 sharing the requested sub_id.
Already fixed: Not applicable — behaviour is current on the default branch (HEAD 5321665d); git log -S 'enforceHwid' -- internal/sub/controller.go returns only 694ad6de. The feature itself landed in 694ad6de "feat(sub): add per-client subscription HWID limits (#5802)" (2026-08-15), after v3.6.0 (2026-07-30), so it exists only in Dev builds — consistent with the reported version.
Duplicate of: None. Related: #6234 and #6245 (both HWID enhancement requests — bulk edit and single-device removal — different asks, no shared root cause)
Evidence: internal/sub/controller.go:617 Hwid: c.GetHeader("X-HWID"),; controller.go:628-631 if !result.Allowed { c.Status(http.StatusNotFound); return false }; internal/web/service/client_hwid.go:100-103 if len(req.Hwid) < minHwidLength { res.NotSupported = true; return res, nil }; client_hwid.go:34 const minHwidLength = 6; client_hwid.go:92-95 limit 0 allows; client_hwid.go:70-77 Select("COALESCE(MAX(limit_hwid), 0)") over sub_id; gate call sites controller.go:390, :714, :765; tests TestSubscriptionHwidGateAcrossBodyRoutes (internal/sub/hwid_controller_test.go:87-98) and TestClientHwidGateRegistersAndBlocks (internal/web/service/client_hwid_test.go:55-61); tooltip text internal/web/translation/en-US.json:743.
Not determined: Whether Clash/Mihomo can be made to send a custom X-HWID header at all — that is third-party client behaviour I cannot verify from this repository. The two curl commands above settle it for your setup: if the header-less request 404s and the one with X-HWID returns 200, the gate is the whole story.

This reply was generated automatically; a maintainer may follow up.

<!-- gh-comment-id:5365479491 --> @github-actions[bot] commented on GitHub (Aug 21, 2026): The 404 is the HWID gate working as written, not a broken subscription: as soon as a client's **HWID Limit** is greater than 0, the panel refuses every machine-readable subscription body for a request that does not carry an `X-HWID` header, and Clash/Mihomo never send that header. So your observation is right, and your conclusion ("Clash/Mihomo do not support the HWID parameter") is right too — it just isn't a defect in the panel, it is the gate's designed behaviour. ### What the code does `internal/sub/controller.go:615-633` — the gate reads the device id straight off the request headers: ```go func (a *SUBController) enforceHwid(c *gin.Context) bool { result, err := a.clientService.EnforceHwidForSubID(c.Param("subid"), service.HwidRequest{ Hwid: c.GetHeader("X-HWID"), ... if !result.Allowed { c.Status(http.StatusNotFound) return false } ``` `internal/web/service/client_hwid.go:100-103` — a missing or too-short `X-HWID` is denied (`Allowed` stays `false`), with `minHwidLength = 6` at `client_hwid.go:34`: ```go if len(req.Hwid) < minHwidLength { res.NotSupported = true return res, nil } ``` The gate runs on all three body routes — raw `/sub/` (`controller.go:390`), `/json/` (`controller.go:714`) and `/clash/` (`controller.go:765`) — and that is pinned by a test, which is why this reads as intended rather than accidental: `TestSubscriptionHwidGateAcrossBodyRoutes` (`internal/sub/hwid_controller_test.go:87-98`) asserts `404` plus `X-Hwid-Not-Supported: true` for `/sub/`, `/json/` **and** `/clash/` when no `X-HWID` header is sent. `TestSubscriptionHwidGateSkipsHtmlInfoPage` (`hwid_controller_test.go:124-134`) pins the opposite for the browser page — which explains why the same link still opens fine in a browser while the client gets a 404. You can confirm it on your own server in two commands (the second one registers a device, see the cleanup note below): ```bash curl -s -o /dev/null -D - -H 'User-Agent: mihomo/1.19' "https://YOUR_HOST/sub/YOUR_SUBID" curl -s -o /dev/null -D - -H 'User-Agent: mihomo/1.19' -H 'X-HWID: test-device-123' "https://YOUR_HOST/sub/YOUR_SUBID" ``` The first returns `404` with `X-Hwid-Active: true` and `X-Hwid-Not-Supported: true`; the second returns `200`. Anything registered that way can be removed with the **HWID Devices** button next to the HWID Limit field in the client edit dialog. ### What you can do today 1. Leave **HWID Limit** at `0` for clients that use Clash/Mihomo — `0` short-circuits the gate before any header is looked at (`client_hwid.go:92-95`: `if limit <= 0 { res.Allowed = true; return res, nil }`), and the limit is stored per client (`LimitHwid`, `internal/database/model/model.go:924`), so a mixed fleet is already possible. 2. One caveat on that: the effective limit is `MAX(limit_hwid)` over all **enabled** clients sharing the same `sub_id` (`client_hwid.go:70-77`). If your Clash user shares a subId with an HWID-limited client, the limit still applies to them. Give them their own subId. 3. Keep HWID Limit only for clients whose app sends `X-HWID` (the feature's own tests use `Happ/1.0` and `Karing/2.0` user agents — an indication of the intended client set, not a compatibility list I can verify from this repository). The rest of your report — "generate the subscription without HWID for clients that don't support it" — is a feature request, not a bug, so I have relabelled the issue `enhancement` (removing `bug`) and left it **open** for a maintainer to decide, rather than closing it. Two notes for whoever picks it up: auto-detecting "unsupported" clients would have to key off the `User-Agent`, which any device can set, so it would weaken the gate it bypasses (my reading, not something the source states); and the HWID Limit tooltip currently says only *"Maximum registered devices for subscription requests. 0 = unlimited."* (`internal/web/translation/en-US.json:743`) — it never warns that a non-zero value makes the link unusable in clients that don't send `X-HWID`, which is what made this look like a bug. Verdict: Not a bug (expected behaviour) Severity: N/A Confidence: High Root cause: No defect. `SUBController.enforceHwid` (`internal/sub/controller.go:615-633`) denies with 404 whenever `ClientService.EnforceHwidForSubID` returns `Allowed=false`, and `client_hwid.go:100-103` returns exactly that for a request whose `X-HWID` header is shorter than `minHwidLength = 6` (`client_hwid.go:34`) — i.e. any client that sends no such header, including Clash/Mihomo. Triggering condition: a client with `limitHwid > 0` sharing the requested `sub_id`. Already fixed: Not applicable — behaviour is current on the default branch (HEAD 5321665d); `git log -S 'enforceHwid' -- internal/sub/controller.go` returns only 694ad6de. The feature itself landed in 694ad6de "feat(sub): add per-client subscription HWID limits (#5802)" (2026-08-15), after v3.6.0 (2026-07-30), so it exists only in Dev builds — consistent with the reported version. Duplicate of: None. Related: #6234 and #6245 (both HWID enhancement requests — bulk edit and single-device removal — different asks, no shared root cause) Evidence: `internal/sub/controller.go:617` `Hwid: c.GetHeader("X-HWID"),`; `controller.go:628-631` `if !result.Allowed { c.Status(http.StatusNotFound); return false }`; `internal/web/service/client_hwid.go:100-103` `if len(req.Hwid) < minHwidLength { res.NotSupported = true; return res, nil }`; `client_hwid.go:34` `const minHwidLength = 6`; `client_hwid.go:92-95` limit 0 allows; `client_hwid.go:70-77` `Select("COALESCE(MAX(limit_hwid), 0)")` over `sub_id`; gate call sites `controller.go:390`, `:714`, `:765`; tests `TestSubscriptionHwidGateAcrossBodyRoutes` (`internal/sub/hwid_controller_test.go:87-98`) and `TestClientHwidGateRegistersAndBlocks` (`internal/web/service/client_hwid_test.go:55-61`); tooltip text `internal/web/translation/en-US.json:743`. Not determined: Whether Clash/Mihomo can be made to send a custom `X-HWID` header at all — that is third-party client behaviour I cannot verify from this repository. The two `curl` commands above settle it for your setup: if the header-less request 404s and the one with `X-HWID` returns 200, the gate is the whole story. *This reply was generated automatically; a maintainer may follow up.* <!-- claude-issue:analyst -->
Sign in to join this conversation.
No milestone
No project
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
MHSanaei/3x-ui#4260
No description provided.