You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The go/log-injection (CWE-117) query identifies log entries that are created from user input without proper sanitisation. The logrus library is vulnerable to this when the default output formatter is used. However, different output formatters, such as JSONFormatter, may sanitise log entries themselves. The go/log-injection query is not currently aware of this behaviour and will report false positives whenever logrus is used for logging and log entries are based on unsanitised user data, even if a sanitising output formatter is used.
Code samples or links to source code
In the following example, go/log-injection will report that the log entry constructed using logrus.Fields depends on a user-provided value that has not been sanitised:
Most likely permanent. We found that accurately diagnosing whether a JSON or other injection-resistant formatter would be in use was too error-prone; we'd either get many false positives or many false negatives whichever way we tried to characterise the situation. Other languages already specify log-injection is a medium-precision query for similar reasons, so we figured best to simply bring the Go query into line.
Would be great to have a way for ignoring a set of CWEs within a scan (like paths-ignore), so people don't have to ignore every single finding for every log-line.
Description of the false positive
The
go/log-injection
(CWE-117) query identifies log entries that are created from user input without proper sanitisation. Thelogrus
library is vulnerable to this when the default output formatter is used. However, different output formatters, such asJSONFormatter
, may sanitise log entries themselves. Thego/log-injection
query is not currently aware of this behaviour and will report false positives wheneverlogrus
is used for logging and log entries are based on unsanitised user data, even if a sanitising output formatter is used.Code samples or links to source code
In the following example,
go/log-injection
will report that the log entry constructed usinglogrus.Fields
depends on a user-provided value that has not been sanitised:The text was updated successfully, but these errors were encountered: