Fuzz introspector
For issues and ideas: https://github.com/ossf/fuzz-introspector/issues

Fuzzer details

Fuzzer: fuzz_jinja_compile_expr

Call tree

The calltree shows the control flow of the fuzzer. This is overlaid with coverage information to display how much of the potential code a fuzzer can reach is in fact covered at runtime. In the following there is a link to a detailed calltree visualisation as well as a bitmap showing a high-level view of the calltree. For further information about these topics please see the glossary for full calltree and calltree overview

Call tree overview bitmap:

The distribution of callsites in terms of coloring is
Color Runtime hitcount Callsite count Percentage
red 0 17 5.12%
gold [1:9] 0 0.0%
yellow [10:29] 0 0.0%
greenyellow [30:49] 0 0.0%
lawngreen 50+ 315 94.8%
All colors 332 100

Fuzz blockers

The following nodes represent call sites where fuzz blockers occur.

Amount of callsites blocked Calltree index Parent function Callsite Largest blocked function
3 0 EP call site: 00000 jinja2.environment.Environment.compile_expression
3 12 jinja2.environment.Environment._tokenize call site: 00012 jinja2.lexer.TokenStream.__init__
2 299 jinja2.parser.Parser._fail_ut_eof call site: 00299 .map
1 7 jinja2.environment.Environment.preprocess call site: 00007 jinja2.environment.Environment.iter_extensions
1 10 jinja2.environment.Environment.iter_extensions call site: 00010 .str
1 75 jinja2.parser.Parser.parse_tuple call site: 00075 jinja2.lexer.describe_token
1 126 jinja2.parser.Parser.parse_subscript call site: 00126 jinja2.parser.Parser.fail
1 138 jinja2.parser.Parser.parse_call_args call site: 00138 jinja2.lexer.TokenStream.look
1 169 jinja2.parser.Parser.parse_test call site: 00169 jinja2.lexer.Token.test_any
1 266 jinja2.parser.Parser.parse_assign_target call site: 00266 jinja2.parser.Parser.parse_primary
1 277 jinja2.parser.Parser.parse_assign_target call site: 00277 .type
1 314 jinja2.parser.Parser.subparse call site: 00314 body.extend

Runtime coverage analysis

Covered functions
425
Functions that are reachable but not covered
43
Reachable functions
114
Percentage of reachable functions covered
62.28%
NB: The sum of covered functions and functions that are reachable but not covered need not be equal to Reachable functions . This is because the reachability analysis is an approximation and thus at runtime some functions may be covered that are not included in the reachability analysis. This is a limitation of our static analysis capabilities.
Warning: The number of covered functions are larger than the number of reachable functions. This means that there are more functions covered at runtime than are extracted using static analysis. This is likely a result of the static analysis component failing to extract the right call graph or the coverage runtime being compiled with sanitizers in code that the static analysis has not analysed. This can happen if lto/gold is not used in all places that coverage instrumentation is used.
Function name source code lines source lines hit percentage hit

Files reached

filename functions hit
/ 1
...fuzz_jinja_compile_expr 3
jinja2.environment 25
jinja2.parser 71
jinja2.lexer 12
jinja2.nodes 9
jinja2.compiler 4

Fuzzer: fuzz_env_jinja_lexer

Call tree

The calltree shows the control flow of the fuzzer. This is overlaid with coverage information to display how much of the potential code a fuzzer can reach is in fact covered at runtime. In the following there is a link to a detailed calltree visualisation as well as a bitmap showing a high-level view of the calltree. For further information about these topics please see the glossary for full calltree and calltree overview

Call tree overview bitmap:

The distribution of callsites in terms of coloring is
Color Runtime hitcount Callsite count Percentage
red 0 14 4.28%
gold [1:9] 0 0.0%
yellow [10:29] 0 0.0%
greenyellow [30:49] 0 0.0%
lawngreen 50+ 313 95.7%
All colors 327 100

Fuzz blockers

The following nodes represent call sites where fuzz blockers occur.

Amount of callsites blocked Calltree index Parent function Callsite Largest blocked function
3 17 jinja2.environment.Environment._tokenize call site: 00017 jinja2.lexer.TokenStream.__init__
2 288 jinja2.parser.Parser._fail_ut_eof call site: 00288 .map
1 12 jinja2.environment.Environment.preprocess call site: 00012 jinja2.environment.Environment.iter_extensions
1 15 jinja2.environment.Environment.iter_extensions call site: 00015 .str
1 131 jinja2.parser.Parser.parse_subscript call site: 00131 jinja2.parser.Parser.fail
1 143 jinja2.parser.Parser.parse_call_args call site: 00143 jinja2.lexer.TokenStream.look
1 174 jinja2.parser.Parser.parse_test call site: 00174 jinja2.lexer.Token.test_any
1 228 jinja2.parser.Parser.parse_tuple call site: 00228 jinja2.lexer.describe_token
1 254 jinja2.parser.Parser.parse_assign_target call site: 00254 jinja2.parser.Parser.parse_primary
1 266 jinja2.parser.Parser.parse_assign_target call site: 00266 .type
1 303 jinja2.parser.Parser.subparse call site: 00303 body.extend

Runtime coverage analysis

Covered functions
425
Functions that are reachable but not covered
45
Reachable functions
115
Percentage of reachable functions covered
60.87%
NB: The sum of covered functions and functions that are reachable but not covered need not be equal to Reachable functions . This is because the reachability analysis is an approximation and thus at runtime some functions may be covered that are not included in the reachability analysis. This is a limitation of our static analysis capabilities.
Warning: The number of covered functions are larger than the number of reachable functions. This means that there are more functions covered at runtime than are extracted using static analysis. This is likely a result of the static analysis component failing to extract the right call graph or the coverage runtime being compiled with sanitizers in code that the static analysis has not analysed. This can happen if lto/gold is not used in all places that coverage instrumentation is used.
Function name source code lines source lines hit percentage hit

Files reached

filename functions hit
/ 1
...fuzz_env_jinja_lexer 6
jinja2.environment 20
jinja2.parser 72
jinja2.lexer 12
jinja2.nodes 9
jinja2.compiler 4

Fuzzer: fuzz_jinja_compile_templates

Call tree

The calltree shows the control flow of the fuzzer. This is overlaid with coverage information to display how much of the potential code a fuzzer can reach is in fact covered at runtime. In the following there is a link to a detailed calltree visualisation as well as a bitmap showing a high-level view of the calltree. For further information about these topics please see the glossary for full calltree and calltree overview

Call tree overview bitmap:

The distribution of callsites in terms of coloring is
Color Runtime hitcount Callsite count Percentage
red 0 51 13.4%
gold [1:9] 0 0.0%
yellow [10:29] 0 0.0%
greenyellow [30:49] 0 0.0%
lawngreen 50+ 327 86.5%
All colors 378 100

Fuzz blockers

The following nodes represent call sites where fuzz blockers occur.

Amount of callsites blocked Calltree index Parent function Callsite Largest blocked function
16 361 jinja2.environment.Environment.compile call site: 00361 jinja2.environment.Environment.compile_templates.write_file
13 32 ...fuzz_jinja_compile_templates.TestOneInput call site: 00032 jinja2.environment.Environment.compile
8 21 jinja2.environment.Environment.__init__ call site: 00021 jinja2.utils.import_string
3 56 jinja2.environment.Environment._tokenize call site: 00056 jinja2.lexer.TokenStream.__init__
2 327 jinja2.parser.Parser._fail_ut_eof call site: 00327 .map
1 51 jinja2.environment.Environment.preprocess call site: 00051 jinja2.environment.Environment.iter_extensions
1 54 jinja2.environment.Environment.iter_extensions call site: 00054 .str
1 154 jinja2.parser.Parser.parse_subscript call site: 00154 jinja2.parser.Parser.fail
1 166 jinja2.parser.Parser.parse_call_args call site: 00166 jinja2.lexer.TokenStream.look
1 197 jinja2.parser.Parser.parse_test call site: 00197 jinja2.lexer.Token.test_any
1 267 jinja2.parser.Parser.parse_tuple call site: 00267 jinja2.lexer.describe_token
1 293 jinja2.parser.Parser.parse_assign_target call site: 00293 jinja2.parser.Parser.parse_primary

Runtime coverage analysis

Covered functions
425
Functions that are reachable but not covered
80
Reachable functions
155
Percentage of reachable functions covered
48.39%
NB: The sum of covered functions and functions that are reachable but not covered need not be equal to Reachable functions . This is because the reachability analysis is an approximation and thus at runtime some functions may be covered that are not included in the reachability analysis. This is a limitation of our static analysis capabilities.
Warning: The number of covered functions are larger than the number of reachable functions. This means that there are more functions covered at runtime than are extracted using static analysis. This is likely a result of the static analysis component failing to extract the right call graph or the coverage runtime being compiled with sanitizers in code that the static analysis has not analysed. This can happen if lto/gold is not used in all places that coverage instrumentation is used.
Function name source code lines source lines hit percentage hit

Files reached

filename functions hit
/ 1
...fuzz_jinja_compile_templates 12
jinja2.environment 47
jinja2.utils 7
jinja2.loaders 5
jinja2.parser 72
jinja2.lexer 12
jinja2.nodes 9
jinja2.compiler 4

Analyses and suggestions

Optimal target analysis

Remaining optimal interesting functions

The following table shows a list of functions that are optimal targets. Optimal targets are identified by finding the functions that in combination, yield a high code coverage.

Func name Functions filename Arg count Args Function depth hitcount instr count bb count cyclomatic complexity Reachable functions Incoming references total cyclomatic complexity Unreached complexity
jinja2.compiler.CodeGenerator.visit_Macro jinja2.compiler 3 ['N/A', 'N/A', 'N/A'] 7 0 5 2 4 56 0 180 145
jinja2.ext.InternationalizationExtension.parse jinja2.ext 2 ['N/A', 'N/A'] 2 0 14 20 11 35 0 125 84
jinja2.compiler.optimizeconst.new_func jinja2.compiler 4 ['N/A', 'N/A', 'N/A', 'N/A'] 5 0 0 2 4 46 0 157 78
jinja2.filters.do_urlize jinja2.filters 7 ['N/A', 'N/A', 'N/A', 'N/A', 'N/A', 'N/A', 'N/A'] 3 0 3 5 5 27 0 90 72
jinja2.filters.async_select_or_reject jinja2.filters 6 ['N/A', 'N/A', 'N/A', 'N/A', 'N/A', 'N/A'] 3 0 1 2 4 25 4 81 72
jinja2.debug.rewrite_traceback_stack jinja2.debug 1 ['N/A'] 3 0 4 3 4 24 0 80 68
jinja2.lexer.Lexer.tokeniter jinja2.lexer 5 ['N/A', 'N/A', 'N/A', 'N/A', 'N/A'] 1 0 11 27 14 19 1 71 56
jinja2.ext.babel_extract jinja2.ext 4 ['N/A', 'N/A', 'N/A', 'N/A'] 43 0 2 5 5 132 0 448 55
jinja2.compiler.CodeGenerator.visit_Template jinja2.compiler 3 ['N/A', 'N/A', 'N/A'] 6 0 44 11 7 54 0 175 53
jinja2.sandbox.SandboxedEnvironment.call jinja2.sandbox 5 ['N/A', 'N/A', 'N/A', 'N/A', 'N/A'] 4 0 1 2 4 16 0 59 44

Implementing fuzzers that target the above functions will improve reachability such that it becomes:

Functions statically reachable by fuzzers
23.0%
170 / 737
Cyclomatic complexity statically reachable by fuzzers
25.0%
636 / 2504

All functions overview

If you implement fuzzers for these functions, the status of all functions in the project will be:

Func name Functions filename Args Function call depth Reached by Fuzzers Fuzzers runtime hit Func lines hit % I Count BB Count Cyclomatic complexity Functions reached Reached by functions Accumulated cyclomatic complexity Undiscovered complexity

Fuzz engine guidance

This sections provides heuristics that can be used as input to a fuzz engine when running a given fuzz target. The current focus is on providing input that is usable by libFuzzer.

/src/fuzz_jinja_compile_expr.py

Dictionary

Use this with the libFuzzer -dict=DICT.file flag


Fuzzer function priority

Use one of these functions as input to libfuzzer with flag: -focus_function name

-focus_function=['jinja2.environment.Environment._tokenize', 'jinja2.parser.Parser._fail_ut_eof', 'jinja2.environment.Environment.preprocess', 'jinja2.environment.Environment.iter_extensions', 'jinja2.parser.Parser.parse_tuple', 'jinja2.parser.Parser.parse_subscript', 'jinja2.parser.Parser.parse_call_args', 'jinja2.parser.Parser.parse_test', 'jinja2.parser.Parser.parse_assign_target']

/src/fuzz_env_jinja_lexer.py

Dictionary

Use this with the libFuzzer -dict=DICT.file flag


Fuzzer function priority

Use one of these functions as input to libfuzzer with flag: -focus_function name

-focus_function=['jinja2.environment.Environment._tokenize', 'jinja2.parser.Parser._fail_ut_eof', 'jinja2.environment.Environment.preprocess', 'jinja2.environment.Environment.iter_extensions', 'jinja2.parser.Parser.parse_subscript', 'jinja2.parser.Parser.parse_call_args', 'jinja2.parser.Parser.parse_test', 'jinja2.parser.Parser.parse_tuple', 'jinja2.parser.Parser.parse_assign_target']

/src/fuzz_jinja_compile_templates.py

Dictionary

Use this with the libFuzzer -dict=DICT.file flag


Fuzzer function priority

Use one of these functions as input to libfuzzer with flag: -focus_function name

-focus_function=['jinja2.environment.Environment.compile', '...fuzz_jinja_compile_templates.TestOneInput', 'jinja2.environment.Environment.__init__', 'jinja2.environment.Environment._tokenize', 'jinja2.parser.Parser._fail_ut_eof', 'jinja2.environment.Environment.preprocess', 'jinja2.environment.Environment.iter_extensions', 'jinja2.parser.Parser.parse_subscript', 'jinja2.parser.Parser.parse_call_args', 'jinja2.parser.Parser.parse_test']

Files and Directories in report

This section shows which files and directories are considered in this report. The main reason for showing this is fuzz introspector may include more code in the reasoning than is desired. This section helps identify if too many files/directories are included, e.g. third party code, which may be irrelevant for the threat model. In the event too much is included, fuzz introspector supports a configuration file that can exclude data from the report. See the following link for more information on how to create a config file: link

Files in report

Source file Reached by Covered by
...fuzz_jinja_compile_expr ['fuzz_jinja_compile_expr'] []
[] []
logging [] []
zipfile [] []
ast [] []
jinja2.parser ['fuzz_jinja_compile_expr', 'fuzz_env_jinja_lexer', 'fuzz_jinja_compile_templates'] []
jinja2.idtracking [] []
re [] []
asyncio [] []
jinja2.ext [] []
jinja2.visitor [] []
importlib [] []
enum [] []
pprint [] []
jinja2.optimizer [] []
collections [] []
stat [] []
functools [] []
jinja2.meta [] []
threading [] []
itertools [] []
pickle [] []
jinja2.lexer ['fuzz_jinja_compile_expr', 'fuzz_env_jinja_lexer', 'fuzz_jinja_compile_templates'] []
jinja2.exceptions [] []
...fuzz_env_jinja_lexer ['fuzz_env_jinja_lexer'] []
gettext [] []
io [] []
urllib [] []
fnmatch [] []
jinja2.nativetypes [] []
jinja2.compiler ['fuzz_jinja_compile_expr', 'fuzz_env_jinja_lexer', 'fuzz_jinja_compile_templates'] []
string [] []
jinja2.constants [] []
hashlib [] []
keyword [] []
jinja2.filters [] []
jinja2.async_utils [] []
jinja2.bccache [] []
jinja2 [] []
atheris [] []
jinja2.debug [] []
[] []
jinja2.nodes ['fuzz_jinja_compile_expr', 'fuzz_env_jinja_lexer', 'fuzz_jinja_compile_templates'] []
posixpath [] []
json [] []
...fuzz_jinja_compile_templates ['fuzz_jinja_compile_templates'] []
jinja2.defaults [] []
sys [] []
_string [] []
textwrap [] []
marshal [] []
jinja2.utils ['fuzz_jinja_compile_templates'] []
typing [] []
traceback [] []
jinja2.environment ['fuzz_jinja_compile_expr', 'fuzz_env_jinja_lexer', 'fuzz_jinja_compile_templates'] []
jinja2.loaders ['fuzz_jinja_compile_templates'] []
tempfile [] []
random [] []
markupsafe [] []
inspect [] []
jinja2.sandbox [] []
jinja2._identifier [] []
os [] []
weakref [] []
jinja2.tests [] []
jinja2.runtime [] []

Directories in report

Directory