fix: reject empty and newline-terminated region names in validate_region_name - #3790
Open
mturac wants to merge 1 commit into
Open
fix: reject empty and newline-terminated region names in validate_region_name#3790mturac wants to merge 1 commit into
mturac wants to merge 1 commit into
Conversation
…ion_name
The host-label regex accepted two inputs that are not valid host
labels: the empty string (because {,63} permits zero repetitions)
and any region ending in \n (because $ matches before a trailing
newline in Python). Change the quantifier to {1,63} and the
end anchor to \Z so both cases now raise InvalidRegionError.
Add TestValidateRegionName with explicit coverage for the
previously-accepted inputs and the existing rejection cases.
Closes boto#3786
1 task
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.
fixes #3786
tightened the host-label regex in
validate_region_name(botocore/utils.py:1338):{,63}changed to{1,63}— rejects empty string, which isnt a valid host label$changed to\Z— rejects trailing newlines (python's$matches before a trailing\n)the validator runs on S3 cross-region redirect path where region comes from server-controlled headers. practical severity is low (downstream
http.clientcatches control chars, and empty region still resolves underamazonaws.com), but function's contract says "valid host label" and these inputs violate that.added
TestValidateRegionNamewith 8 tests covering valid regions, empty string, trailing newline, spaces, leading/trailing hyphens, numeric-only, andNone. verified with the exact reproduction script from the issue.