Skip to content

feat(scope): accept *.example.com in asset scope - #520

Merged
BaaRai merged 1 commit into
BaaRai:mainfrom
Phantom-IN:feat/scope-wildcard-domains
Nov 23, 2026
Merged

BaaRai merged 1 commit into
BaaRai:mainfrom
Phantom-IN:feat/scope-wildcard-domains

Conversation

@Phantom-IN

Copy link
Copy Markdown
Contributor

Step 1 of #519.

Bug bounty scope pages list in-scope domains as *.example.com. Pasting that into a company's or a task's asset scope fails twice. The web editor marks the line as invalid, and ParseScopeLine rejects it with not recognizable as a valid domain/IP/CIDR: *.example.com. So each wildcard line has to be rewritten by hand.

Change

  • scopeHostname drops a leading *. label and reports that it did. ParseScopeLine stores the line as the example.com domain rule. Company scope and task root_domain scope match assets on their registrable domain, so that rule already covers the subdomains, and nothing changes in the matching.
  • The wildcard is only accepted when what's left is a registrable domain (eTLD+1). *.api.example.com would become a rule that matches no asset, so it's rejected with an explicit message rather than stored as a dead rule. *.co.uk, *.com and *.1.2.3.4 are rejected too. Whether a single subdomain like api.example.com should get its own subdomain rule is the open question in [Feature request] Paste a bug bounty program's scope (in scope, out of scope, wildcards) when creating a task #519, and I left it alone here.
  • web/src/lib/company-scope.ts: domainHostname strips the same leading label, so the editor accepts the line and the preview and deduplication see example.com. A deeper wildcard passes the client check and is refused by the server with the message above, since the client has no public-suffix list.

Note that *.example.com also covers the apex example.com here, because that is what the domain rule covers today. That is the first question in #519. If you'd rather exclude the apex, I'll change it.

Tests

  • TestParseScopeLine / TestParseAutoScopeLine: wildcard domain, wildcard URL with port and mixed case, IDN, and the rejected forms (*.api.example.com, *.co.uk, *.com, *.1.2.3.4, api.*.example.com, *example.com). On main the accepting cases fail with the error above.
  • New TestCompanyScopeWildcardAttribution (Postgres): a *.<root> company scope stores <root> and attributes api.<root> to the company.
  • go test -p 1 ./db/ ./server/ against Postgres 16: db passes. In server, TestManagerSOCKS5UDPOptInAndAssetBlockRuleDropsDatagram and TestPauseShiftsTaskDeadlineOnResume fail on my Mac, the same as on main (the first needs 127.0.0.2).
  • go vet, gofmt, tsc --noEmit and biome check on the changed file are clean. I checked the web parser by running it under node with the t import stubbed.

Bug bounty programs write a domain and its subdomains as *.example.com.
ParseScopeLine rejected that line ("not recognizable as a valid
domain/IP/CIDR"), and the web scope editor rejected it before it reached
the server, so every wildcard line had to be rewritten by hand.

Drop a leading "*." label and store the line as the example.com domain
rule. Company and task scope match assets on their registrable domain, so
that rule already covers the subdomains. The wildcard is accepted only on
a registrable domain: *.api.example.com would store a rule that matches
nothing, so it is rejected along with *.co.uk and *.<IP>.

Step 1 of BaaRai#519.
@BaaRai
BaaRai merged commit 0c64c39 into BaaRai:main Nov 23, 2026
7 checks passed
@BaaRai

BaaRai commented Nov 23, 2026

Copy link
Copy Markdown
Owner

Merged. Thanks @Phantom-IN for the wildcard scope: *.example.com now stores the example.com domain rule, the deeper wildcard forms are refused with a clear message, and the editor and the dedupe agree on the normalized value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants