mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[PR #6242] [MERGED] fix(reality): make the REALITY target check usable on a private network #6196
Labels
No labels
backlog
bug
clarification needed
documentation
duplicate
enhancement
github_actions
good first issue
invalid
javascript
New Feature
PR welcomed
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
MHSanaei/3x-ui#6196
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?
📋 Pull Request Information
Original PR: https://github.com/MHSanaei/3x-ui/pull/6242
Author: @shustovTE
Created: 8/17/2026
Status: ✅ Merged
Merged: 8/18/2026
Merged by: @MHSanaei
Base:
main← Head:claude/local-network-cert-check-n49my4📝 Commits (3)
9e067b8fix(reality): make the REALITY target check usable on a private network93ebce3fix(reality): recover from a stale SNI and report a refused address reliably485319aMerge branch 'main' into claude/local-network-cert-check-n49my4📊 Changes
26 files changed (+294 additions, -73 deletions)
View changed files
📝
frontend/public/openapi.json(+17 -1)📝
frontend/src/generated/examples.ts(+2 -0)📝
frontend/src/generated/schemas.ts(+12 -0)📝
frontend/src/generated/types.ts(+2 -0)📝
frontend/src/generated/zod.ts(+2 -0)📝
frontend/src/pages/api-docs/endpoints.ts(+4 -1)📝
frontend/src/pages/inbounds/form/InboundFormModal.tsx(+3 -1)📝
frontend/src/pages/inbounds/form/security/reality.tsx(+43 -22)📝
frontend/src/pages/inbounds/form/useSecurityActions.ts(+44 -8)📝
internal/util/netsafe/netsafe.go(+16 -2)📝
internal/web/controller/server.go(+4 -3)📝
internal/web/service/reality_scan.go(+65 -33)📝
internal/web/service/reality_scan_test.go(+2 -2)📝
internal/web/translation/ar-EG.json(+6 -0)📝
internal/web/translation/en-US.json(+6 -0)📝
internal/web/translation/es-ES.json(+6 -0)📝
internal/web/translation/fa-IR.json(+6 -0)📝
internal/web/translation/id-ID.json(+6 -0)📝
internal/web/translation/ja-JP.json(+6 -0)📝
internal/web/translation/pt-BR.json(+6 -0)...and 6 more files
📄 Description
Summary
The REALITY target check now works against a target that is only reachable inside the
deployment (a Docker service name, a LAN address) after an explicit confirmation, sends the
inbound's
serverNamesas SNI the way clients do, and reports the certificate it actuallysaw instead of hiding it behind "Not trusted".
Why
Two separate things made the check report a red verdict on a healthy configuration.
netsafe.SSRFGuardedDialContext, which rejects loopback, privateand link-local addresses, so a fronting service reachable only by its compose service name
always failed with
connection failed: blocked private/internal address fdd1:f2da:86b4::2.The inbound itself saves and works — the guard sits only in the probe path — so the panel
contradicted reality and pushed operators to publish the fronting port on
0.0.0.0just tomake the check agree.
serverNames, so a fronting proxy answered the probe with its default certificate:a Traefik front reached as
traefikreportedcertificate not trusted: x509: certificate is valid for <hash>.traefik.default, not traefik,while the same target probed with SNI
***.***.compresents a valid Let's Encrypt chain.On top of that the result panel showed only "Not trusted" and dropped the subject/issuer —
exactly the information needed to tell a wrong-SNI probe from a genuinely bad target.
Rather than a panel-wide setting that permanently lifts the SSRF guard, the guard is lifted per
probe, only after the operator confirms it, and the verdict keeps saying the check ran over an
internal network.
Type of change
Areas affected
What changed
netsafe.ErrPrivateAddressBlocked— a sentinel so a caller can tell a guard refusal apartfrom an ordinary connection failure.
RealityScanResult.privateTarget— set when the target resolves to a loopback/privateaddress, both when the guard refused it and when the confirmed probe reached it.
ScanRealityTarget(target, sni, xver, allowPrivate);POST /panel/api/server/scanRealityTargetgains the optional form fields
sniandallowPrivate. No new endpoint, no new setting.privateTargetverdict opens a confirmation modal naming the target; only theconfirmed retry carries
allowPrivate=true. The result alert stays a warning with"Checked over a private/local network …" even when the target is feasible.
trusted" is appended rather than replacing the certificate details.
targetstays the dialled address, so a passing check no longer rewrites theTarget field with the SNI host; certificate names are copied into the SNI field only when the
chain verified (otherwise a proxy's default-certificate name would become the next SNI).
ScanRealityTargets) keeps the guard unconditionally — honouring theopt-in there would turn it into an internal network scanner.
en-USstrings plus all 12 other locales.How was this tested?
Automated:
go test ./internal/web/..., including three new cases ininternal/web/service/reality_scan_test.godriven against a realhttptest.NewTLSServeron loopback:
TestScanRealityTargetBlocksPrivate— the refusal setsprivateTargetso the panel canoffer the opt-in.
TestScanRealityTargetAllowPrivateReportsCertificate— with the opt-in the handshakecompletes and subject/issuer/expiry come back, while
certValidstays false for theself-signed chain and
privateTargetstays set.TestScanRealityTargetUsesSNI— the httptest certificate is issued forexample.com:SNI
example.compasses the hostname check and returns it inserverNames, SNItraefikreports
not traefik, an invalid SNI is rejected, andtargetkeeps the dialled address.npm run test(1070 tests), plus a new case infrontend/src/test/inbound-form-blocks.test.tsxasserting the result panel showssubject (issuer)with "Not trusted" and the local-network note, and that clicking "Scan"calls the handler with no argument (a plain click must not reach
allowPrivate).Both new frontend assertions were verified to fail before the fix.
npm run lint,npm run typecheck,npm run build,make genclean.Manual, on a Docker deployment fronted by Traefik (panel in the same compose network):
reality, Targettraefik:443, SNI empty → Scan:confirmation modal appears naming the target; Cancel sends nothing.
(
certificate is valid for <hash>.traefik.default, not traefik), with subject, issuer andexpiry visible and the local-network note shown.
***.***.com) → Scan → confirm → TLS 1.3 /h2 / X25519MLKEM768, the Let's Encrypt certificate without "Not trusted", Target still
traefik:443, and the alert still marked as checked over a private network.Screenshots / recordings
Breaking changes
None. Both new request fields are optional and default to the previous behaviour: with no
allowPrivatea private target is still refused, and with nosnithe target host is stillused as SNI. The response gains one field (
privateTarget).Two intentional behaviour changes, neither requiring action from users: a scan no longer
overwrites the Target field with the SNI host, and certificate names are copied into the SNI
field only when the certificate chain verified.
Checklist
go build ./...and the test suite pass locally.npm run lint,npm run typecheck, andnpm run buildpass.(
frontend/src/pages/api-docs/endpoints.ts+ regeneratedfrontend/public/openapi.json;docs/public/openapi.jsonwas already behind these endpoints before this branch, so it isleft untouched — happy to sync it separately.)
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.