Skip to content

fix(portal): allow single-label container hostnames in private network validation - #188

Open
elf-mouse wants to merge 1 commit into
yc-software:mainfrom
elf-mouse:fix/portal-single-label-hostname
Open

fix(portal): allow single-label container hostnames in private network validation#188
elf-mouse wants to merge 1 commit into
yc-software:mainfrom
elf-mouse:fix/portal-single-label-hostname

Conversation

@elf-mouse

@elf-mouse elf-mouse commented Aug 4, 2026

Copy link
Copy Markdown

When running under Docker Compose, internal upstream services (such as the authentication broker http://auth:8080) use bare single-label hostnames without dots (e.g. auth).

The previous isPrivateNetworkUrl check rejected any non-IP host missing a domain extension or .local suffix, causing portal boot checks to fail with a misconfiguration error.

This commit updates isPrivateNetworkUrl to accept single-label hostnames (!host.includes(.)) as valid private network hosts.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

…k validation

When running under Docker Compose, internal upstream services (such as the authentication broker `http://auth:8080`) use bare single-label hostnames without dots (e.g. `auth`).

The previous `isPrivateNetworkUrl` check rejected any non-IP host missing a domain extension or `.local` suffix, causing portal boot checks to fail with a misconfiguration error.

This commit updates `isPrivateNetworkUrl` to accept single-label hostnames (`!host.includes(.)`) as valid private network hosts.

@rajpratham1 rajpratham1 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a small, targeted fix that addresses a realistic deployment scenario without broadening the trust model in a concerning way.

What the PR does well
Fixes a real compatibility issue
Previously, only localhost, certain private domains (.internal, .flycast, .local), and private IP ranges were considered trusted.
This change additionally allows single-label hostnames (e.g. http://auth:8080), which are commonly used for service discovery inside Docker Compose, Kubernetes, and other private container networks.
Minimal change

The implementation is a single condition:

|| !host.includes(".")
This keeps the logic simple and doesn't affect existing trusted hostname checks.
Regression test included

The test adds:

http://auth:8080

ensuring this deployment scenario remains supported in the future.

Security considerations

I don't see this as introducing a significant security risk because:

The validation still requires an http or https URL.
Single-label hostnames are generally not publicly resolvable via normal DNS and are primarily used within private networks.
Existing checks for localhost, .internal, .flycast, and RFC1918 IPs remain unchanged.
Minor observation (non-blocking)

Using !host.includes(".") also accepts any single-label hostname (e.g. printer, db, redis, foo). That is likely intentional for containerized environments, but if the project ever needs stricter validation, a comment explaining that this is specifically to support Docker/Kubernetes service names would improve readability.

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