Repository navigation
fix(waf): reject a trailing line break in deny paths - #451
Open
Crackhead-gsk wants to merge 1 commit into
Open
Crackhead-gsk wants to merge 1 commit into
Crackhead-gsk wants to merge 1 commit into
Conversation
PATH_PATTERN ended in $ without the D modifier, so a value such as "/a\n" passed isValidPath(). The value is written into generated reverse proxy configuration, where a newline starts a new line. Add the D modifier and test line breaks, unsafe paths and the IP check.
Contributor
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 41 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. CodeRabbit Verify
|
This branch has not been deployed
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.
What
WebSpaceWafRules::isValidPath()accepts a path with a trailing line break (for example/afollowed by a newline).Cause
PATH_PATTERNends in$without theD(dollar-end-only) modifier. In PCRE,$also matches right before a final newline, so"/a\n"passes the check. The class exists to make sure only plain paths end up in the generated reverse proxy configuration, and a newline in a value starts a new config line there.isValidIp()is not affected: its first check rejects every character outside0-9 A-F a-f : . /, which includes line breaks.Fix
Add the
Dmodifier toPATH_PATTERN(the only place it is used). Nothing else changes.Tests
backend/tests/Helpers/WebSpaceWafRulesTest.php(4 tests, 36 assertions): ordinary paths still pass, trailing/inner line breaks are rejected, unsafe paths (traversal,.well-known, quotes, braces, over-length) are rejected, and the IP check rejects line breaks and bad prefixes.PHPUnit 11 against this branch: OK. Against current
developthe line-break test fails on"/a\n"and the other three pass, so only the reported behaviour changes.Verified / not verified
php -l.develop, and the generated proxy config was not inspected; the change only tightens input validation.