Skip to content

feat(container): reject hostnames with leading or trailing hyphens - #209

Open
nidsnitesh wants to merge 1 commit into
openai:mainfrom
nidsnitesh:fix/entrypoint-hostname-validation
Open

feat(container): reject hostnames with leading or trailing hyphens#209
nidsnitesh wants to merge 1 commit into
openai:mainfrom
nidsnitesh:fix/entrypoint-hostname-validation

Conversation

@nidsnitesh

Copy link
Copy Markdown

Summary

Hardens the CODEX_SECURITY_GIT_HOST validation in docker/entrypoint.sh to reject hostnames starting or ending with hyphens.

Details

Previously, the POSIX case pattern 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.com or --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

  • Added -*|*- to the rejection case pattern in docker/entrypoint.sh.
  • Added corresponding test assertions in sdk/typescript/tests-ts/container-entrypoint.test.ts.

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.
@github-actions github-actions Bot added the bug Something isn't working label Aug 2, 2026
@mldangelo-oai mldangelo-oai added enhancement New feature or request and removed bug Something isn't working labels Aug 3, 2026
@mldangelo-oai mldangelo-oai changed the title fix: reject hyphen-prefixed hostnames in entrypoint.sh feat(container): reject hostnames with leading or trailing hyphens Aug 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants