-
Notifications
You must be signed in to change notification settings - Fork 1.7k
[Go] Add Unicode Bypass Validation query, test and help file #12994
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
QHelp previews: go/ql/src/experimental/CWE-176/UnicodeBypassValidation.qhelpBypass Logical Validation Using Unicode CharactersSecurity checks bypass due to a Unicode transformation If ever a unicode tranformation is performed after some security checks or logical validation, the latter could be bypassed due to a potential Unicode characters collision. The validation of concern are any character escaping, any regex validation or any string verification. RecommendationPerform a Unicode normalization before the logical validation. ExampleThe following example showcases the bypass of all checks performed by For instance: the character U+FE64 ( package main
import (
"fmt"
"html"
"net/http"
"golang.org/x/text/unicode/norm"
)
func main() {}
func bad() {
http.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) {
unicode_input := req.URL.Query().Get("unicode_input")
escaped := html.EscapeString(unicode_input)
unicode_norm := norm.NFKC.String(escaped)
fmt.Println(w, "Results: %q", unicode_norm)
})
} References
|
go/ql/lib/semmle/go/security/UnicodeBypassValidationCustomizations.qll
Outdated
Show resolved
Hide resolved
Sorry about the delay, I will be working on this query this weekend. |
Co-authored-by: Chris Smowton <smowton@github.com>
Co-authored-by: Chris Smowton <smowton@github.com>
Co-authored-by: Chris Smowton <smowton@github.com>
go/ql/src/change-notes/2013-05-02-post-unicode-normalization-query.md
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly looks good, couple more adjustments
Co-authored-by: Chris Smowton <smowton@github.com>
Co-authored-by: Chris Smowton <smowton@github.com>
A regex match function calls could be used as a barrier guard, commit a64a998. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking good now! I note the bounty application wants you to submit a Golang CVE -- once that's done I think securitylab will now proceed to check his query's accuracy.
Thanks, no problem @smowton |
This pull request adds a Unicode Bypass Validation (UBV) query, tests, and the help file.
The UBV query checks for a Post-Unicode Normalization in a Golang codebase that leads to some security issues such as the bypasses of a String validation, regex verification, and escape functions.