Skip to content

Commit f6194b5

Browse files
committed
CleartextLogging: sanitize strings.Split(authheader, ":")[0] and similar
These can represent a username, method name or other non-sensitive component of an Authorization header. For greater precision we could split the query into one investigating Authorization headers and one investigating other sources of sensitive data that can't be sanitized by splitting this way.
1 parent 102237b commit f6194b5

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

ql/src/semmle/go/security/CleartextLoggingCustomizations.qll

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,4 +183,22 @@ module CleartextLogging {
183183

184184
override string describe() { result = "HTTP request headers" }
185185
}
186+
187+
/**
188+
* The first element of a split by ' ' or ':', often sanitizing a username/password pair
189+
* or the "Method value" syntax used in the HTTP Authorization header.
190+
*/
191+
private class NonSensitiveAuthorizationElement extends Barrier, DataFlow::ElementReadNode {
192+
NonSensitiveAuthorizationElement() {
193+
exists(DataFlow::CallNode splitCall, DataFlow::Node splitAlias |
194+
splitCall
195+
.getTarget()
196+
.hasQualifiedName("strings", ["Split", "SplitN", "SplitAfter", "SplitAfterN"]) and
197+
splitCall.getArgument(1).getStringValue() = [" ", ":"] and
198+
DataFlow::localFlow(splitCall.getResult(), splitAlias) and
199+
this.getBase() = splitAlias
200+
) and
201+
this.getIndex().getIntValue() = 0
202+
}
203+
}
186204
}

0 commit comments

Comments
 (0)