Repository navigation
[Enhancement] Support http://*.onion in cors.allowedOrigins #46
Copy link
Copy link
Labels
IPFSFile sharing, decentralized storage, and IPFS-specific featuresFile sharing, decentralized storage, and IPFS-specific featuresSecurityTopics about security approaches, cryptography, authentication, or vulnerabilitiesTopics about security approaches, cryptography, authentication, or vulnerabilitiesenhancementNew feature or requestNew feature or request
Description
Summary
Tor and other .onion frontends call the IPFS Node REST API from the browser with an Origin of http://<hidden-service>.onion. Today each onion must be listed as an exact entry in cors.allowedOrigins. When a messenger or site hidden service is re-keyed, operators must update every IPFS node config in sync.
A wildcard entry such as http://*.onion is the natural fix, but the current CORS parser rejects it at startup because validateHostname() requires a dot in the wildcard suffix (onion alone fails).
Current behavior
- Wildcard rules use the form
https://*.example.organd match any-depth subdomains ofexample.org. http://*.onionfails during config load withInvalid wildcard CORS hostname: onion(seevalidateHostname()insrc/security/cors.ts).- Operators work around this by adding exact origins, for example Tor PWA hidden services on mainnet deployments.
Observed in production (ADAMANT mainnet, 2026-09-28)
- IPFS hidden services on ipfs4/ipfs6 (
z455…onion,3ytwoe62…onion) proxy to the sameipfs-nodeAPI as clearnet nginx. - The Tor messenger PWA is served from a different onion (for example
adamant6457join…onion), not from the IPFS HS hostnames inwallets/tor.json. - When the PWA origin is listed exactly,
GET /api/node/inforeturnsAccess-Control-Allow-Originfor that onion and probes succeed over Tor. - Tor Browser (Firefox) often sends
Origin: null(not the PWA onion) on cross-.onionfetches from the PWA to the IPFS onions. The API still returns HTTP 200, but withoutAccess-Control-Allow-Origin, so the client reports CORS failure and nodes show Offline. This is separate from the wildcard issue: it needs an explicitnullentry incors.allowedOrigins(literal four-character string) or a client-side change. Document the trade-off (any opaque origin) in security docs.
Proposed behavior
- Accept
http://*.onion(and optionallyhttps://*.onionif ever used) as a wildcard suffix rule. - Match browser origins whose hostname is a valid v3 onion name (56-character base32 label +
.onion) or a subdomain thereof, using the same path/port/credentials rules as existing HTTP(S) wildcards. - Reject bare
http://*.onionpaths with userinfo, query, fragment, or non-canonical forms, consistent with other CORS entries. - Document the rule in
docs/guide/configuration.mdanddocs/guide/security.md, and mention it in the Adamant Messenger integration guide where Tor PWA origins are discussed. - Document the optional
nullorigin entry for Tor Browser cross-onion behavior alongside Tor wildcard guidance.
Security and scope
- This is an explicit deployer opt-in; default
config.default.json5should keep Tor onions commented or absent so new standalone deployments do not open CORS to all.onionsites by default. - Wildcard
.onionis broader than a single HS hostname but still limited to the.onionnamespace (not public clearnet). Call out in docs that any Tor site the user can reach could call the API if the node is reachable. - The
nullentry is broader still (any opaque browser origin). Keep it commented in defaults; mention it only for meshes that must support Tor Browser cross-onion clients until the client or browser behavior changes. - Do not add a bare
*or relax non-onion wildcards.
Acceptance criteria
cors.allowedOriginscontaininghttp://*.onionpassesvalidateConfigand starts the server.createOriginMatcherreturns true for representative Tor PWA and IPFS onion origins and false for unrelated hosts (for examplehttps://evil.example.org,http://short.onion).- Unit tests cover parsing, matching, and rejection of malformed entries.
- Configuration and security docs list the new pattern alongside existing wildcard rules.
- Adamant Messenger guide mentions Tor PWA
http://*.onionand theOrigin: nullcase.
Related context
- Desktop Electron clients use exact
app://.origins (see closed [Composite] Close 0.1.0 adoption gaps: desktop CORS, proxy docs, upload diagnostics #44 / PR Fix: Allow desktop CORS and name upload failures #45). - Production ADAMANT meshes temporarily listed exact Tor PWA onions in node config until this enhancement ships.
- Implementation can ship in the same change set as
nullorigin support if maintainers agree; keep them documented as separate opt-in entries.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
IPFSFile sharing, decentralized storage, and IPFS-specific featuresFile sharing, decentralized storage, and IPFS-specific featuresSecurityTopics about security approaches, cryptography, authentication, or vulnerabilitiesTopics about security approaches, cryptography, authentication, or vulnerabilitiesenhancementNew feature or requestNew feature or request
Type
Projects
- StatusShow more project fieldsReleased IPFS node v0.1.0
Activity
metalisk commentedon Sep 28, 2026
Follow-up for Tor Browser
Origin: null/ cross-onion CORS: #48