fix(security): close shell denylist bypass vectors#820
fix(security): close shell denylist bypass vectors#820GoCeylan wants to merge 4 commits intosipeed:mainfrom
Conversation
There was a problem hiding this comment.
I think these regular expression should be compiled in a list of text instead of changing the code all the time
|
Regex guards are trivially bypassable. Variable indirection ( |
|
|
Hey @blib you are technically correct, this solution is good as a stop gap. Your PR is the long-term fix, the tradeoff is complexity; it is 2500 lines and a new dependancy. For now let's implement @sky5454 's suggestion of gathering to a txt file, then proceed with refining your PR. |
|
@sky5454 regex denylist now lives in a standalone text file. |
sky5454
left a comment
There was a problem hiding this comment.
It is recommended that you include the parsing of TXT, which is helpful for CI
| return fmt.Errorf("invalid allow pattern %q: %w", p, err) | ||
| } | ||
| t.allowPatterns = append(t.allowPatterns, re) | ||
| compiled, err := compileRegexPatterns(patterns) |
There was a problem hiding this comment.
This encapsulates the regular expression, and the error printing is moved to the compiler egexpatterns function. Good
|
@sky5454 Added |
1767e30 to
e98a491
Compare
|
@GoCeylan Hi! This PR has had no activity for over 2 weeks, so I'm closing it for now to keep things organized. Feel free to reopen anytime if you'd like to continue. |
📝 Description
Fixes 5 bypass patterns in the shell command deny list that could allow prompt injection attacks to execute arbitrary commands on the device.
Bypasses closed:
. evil.shwas not caught (onlysourcekeyword was blocked)| /bin/bashbypassed| bashcheck.sh:source /etc/profilebypassed the.shextensionrequirement
bash <<< "cmd"was not caughtsu -c: sudo alternative was not blockedAdds 13 test cases covering each bypass vector.
🗣️ Type of Change
🤖 AI Code Generation
🔗 Related Issue
Security audit finding, no existing issue.
📚 Technical Context (Skip for Docs)
🧪 Test Environment
📸 Evidence (Optional)
13 new subtests in
TestShellTool_DenylistBypassescovering each vector.Run with:
go test ./pkg/tools/ -run TestShellTool_DenylistBypasses -v☑️ Checklist