Skip to content

reject trailing newline in host label validators#3724

Open
metsw24-max wants to merge 1 commit into
boto:developfrom
metsw24-max:host-label-validator-newline
Open

reject trailing newline in host label validators#3724
metsw24-max wants to merge 1 commit into
boto:developfrom
metsw24-max:host-label-validator-newline

Conversation

@metsw24-max

Copy link
Copy Markdown

botocore's host label validators all anchor with $, which in Python also matches just before a trailing newline, so a value such as us-east-1\n, mybucket\n or a data\n host prefix passes validation and the unchanged string is then used to build the request host. validate_region_name even documents that its argument must be a valid host label, yet it accepts the newline, and the same gap exists in validate_bucket_name, the HeaderToHostHoister hostname check, the S3ControlEndpointSetter host label check and the serialiser host prefix check. The region case is the most exposed because that value can be sourced from an S3 cross-region redirect response and then feeds endpoint resolution and the SigV4 signing scope. is_valid_endpoint_url already screens for \t\r\n through UNSAFE_URL_CHARS, so these label validators are the remaining place a control character can slip past. I moved the trailing anchor to \Z in each one so a match has to reach the actual end of the string, and left the ARN and resource regexes alone since those re-extract a clean label and never carry a newline through. Valid regions, bucket names and host labels behave exactly as before.

@metsw24-max

Copy link
Copy Markdown
Author

gentle ping

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.

1 participant