feat(container): reject hostnames with leading or trailing hyphens - #209
Open
nidsnitesh wants to merge 1 commit into
Open
feat(container): reject hostnames with leading or trailing hyphens#209nidsnitesh wants to merge 1 commit into
nidsnitesh wants to merge 1 commit into
Conversation
The CODEX_SECURITY_GIT_HOST validation previously allowed hostnames starting or ending with a hyphen (e.g. '-evil.com' or '--flag.com'). Per RFC 952 and RFC 1123, hostname labels must start and end with an alphanumeric character. Hyphen-prefixed hostnames could also be parsed as command-line flags in downstream tooling. This commit updates the POSIX case pattern in entrypoint.sh to explicitly reject hostnames starting with '-*' or ending with '*-', and adds unit test coverage in container-entrypoint.test.ts.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Hardens the
CODEX_SECURITY_GIT_HOSTvalidation indocker/entrypoint.shto reject hostnames starting or ending with hyphens.Details
Previously, the POSIX
casepattern checked for empty strings, leading/trailing dots, consecutive dots, and characters outside[A-Za-z0-9.-]. However, strings starting or ending with a hyphen (such as-evil.comor--flag.com) passed validation.Per RFC 952 / RFC 1123 standards, hostnames must start and end with an alphanumeric character. Hyphen-prefixed strings could also be interpreted as option flags when interpolated into commands or configuration keys.
Fix
-*|*-to the rejection case pattern indocker/entrypoint.sh.sdk/typescript/tests-ts/container-entrypoint.test.ts.