Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix format string vulnerability in using agerr() to report errors dur…
…ing parsing. We now use a fixed format %s, and pass the error string as an argument.
- Loading branch information
99eda42
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.
How to exploit this "format string vulnerability" with old versions ?
99eda42
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.
See https://www.owasp.org/index.php/Format_string_attack
99eda42
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.
In case anyone is wondering how to cherry-pick this to 2.38 (as I was), I found a patch from Ubuntu at this Debian bug.
Note: I'm not a graphviz developer; this is not authoritative :-)
99eda42
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.
Is there any known way to make
yytext
contain the format string?I see it's possible to inject format string via file name and (after dc6f1e0) via unclosed qstring or hstring, but I've not got to get it to
yytext
.Quick grep over sources found few other
agerr()
calls with second argument not being a fixed string.https://github.com/ellson/graphviz/blob/31158b1/lib/cgraph/scan.l#L168
Same file,
chkNum()
function. Format string can be injected via graph file name:https://github.com/ellson/graphviz/blob/31158b1/lib/graph/lexer.c#L463
https://github.com/ellson/graphviz/blob/31158b1/lib/graph/lexer.c#L469
https://github.com/ellson/graphviz/blob/31158b1/lib/graph/lexer.c#L472
libgraph is deprecated since 2.30.0. In older graphviz versions, format string can be injected via graph file content.
https://github.com/ellson/graphviz/blob/31158b1/cmd/tools/gmlscan.l#L130
This case would require format string in
yytext
, so it's unclear to me if it's possible or not.