@@ -25,6 +25,30 @@ using Jest in `.jazzerjsrc.json`:
2525Hooks all relevant functions of the built-in modules ` fs ` and ` path ` and reports
2626a finding if the fuzzer could pass a special path to any of the functions.
2727
28+ The Path Traversal bug detector can be configured in the
29+ [ custom hooks] ( ./fuzz-settings.md#customhooks--arraystring ) file.
30+
31+ - ` ignore(rule) ` - suppresses findings from callsites matching the shown stack
32+ excerpt.
33+ - ` stackPattern ` accepts either a string or a ` RegExp ` and is matched against
34+ the shown stack excerpt after removing the leading ` Error ` line and Jazzer.js
35+ frames. The remaining stack text is matched as shown, including path
36+ separators and column numbers.
37+
38+ Here is an example configuration in the
39+ [ custom hooks] ( ./fuzz-settings.md#customhooks--arraystring ) file:
40+
41+ ``` javascript
42+ const { getBugDetectorConfiguration } = require (" @jazzer.js/bug-detectors" );
43+
44+ getBugDetectorConfiguration (" path-traversal" )? .ignore ({
45+ stackPattern: " safe-path-wrapper.js:41" ,
46+ });
47+ ` ` `
48+
49+ Findings also print a generic example suppression snippet. Copy/paste it and
50+ adapt ` stackPattern` to the shown stack excerpt.
51+
2852_Disable with:_ ` -- disableBugDetectors= path- traversal` in CLI mode; or when
2953using Jest in ` .jazzerjsrc .json ` :
3054
@@ -98,17 +122,58 @@ using Jest in `.jazzerjsrc.json`:
98122{ " disableBugDetectors" : [" prototype-pollution" ] }
99123` ` `
100124
101- ## Remote Code Execution
125+ ## Code Injection
126+
127+ Installs a canary on ` globalThis ` and hooks the ` eval` and ` Function ` functions.
128+ The before-hooks guide the fuzzer toward injecting the active canary identifier
129+ into code strings. The detector reports two fatal stages by default:
102130
103- Hooks the ` eval` and ` Function ` functions and reports a finding if the fuzzer
104- was able to pass a special string to ` eval` and to the function body of
105- ` Function ` .
131+ - ` Potential Code Injection (Canary Accessed)` - some code resolved the canary.
132+ This high-recall heuristic catches cases where dynamically produced code reads
133+ or stores the canary before executing it later.
134+ - ` Confirmed Code Injection (Canary Invoked)` - the callable canary returned by
135+ the getter was invoked.
106136
107- _Disable with:_ ` -- disableBugDetectors= remote- code- execution` in CLI mode; or
108- when using Jest in ` .jazzerjsrc .json ` :
137+ The detector can be configured in the
138+ [custom hooks](./fuzz-settings.md#customhooks--arraystring) file.
139+
140+ - ` disableAccessReporting` - disables the stage-1 access finding while keeping
141+ invocation reporting active.
142+ - ` disableInvocationReporting` - disables the stage-2 invocation finding.
143+ - ` ignoreAccess (rule)` - suppresses stage-1 findings matching the shown stack
144+ excerpt.
145+ - ` ignoreInvocation (rule)` - suppresses stage-2 findings matching the shown
146+ stack excerpt.
147+ - ` stackPattern` accepts either a string or a ` RegExp ` and is matched against
148+ the shown stack excerpt after removing the leading ` Error ` line and Jazzer.js
149+ frames. The remaining stack text is matched as shown, including path
150+ separators and column numbers.
151+
152+ The detector must be able to install a canary on at least one active global
153+ object. Locked-down environments that forbid this should disable the detector
154+ explicitly.
155+
156+ Here is an example configuration in the
157+ [custom hooks](./fuzz-settings.md#customhooks--arraystring) file:
158+
159+ ` ` ` javascript
160+ const { getBugDetectorConfiguration } = require (" @jazzer.js/bug-detectors" );
161+
162+ getBugDetectorConfiguration (" code-injection" )
163+ ? .ignoreAccess ({
164+ stackPattern: " handlebars/runtime.js:87" ,
165+ })
166+ ? .disableInvocationReporting ();
167+ ` ` `
168+
169+ Findings print a generic example suppression snippet. Copy/paste it and adapt
170+ ` stackPattern` to a stable substring or ` RegExp ` from the shown stack.
171+
172+ _Disable with:_ ` -- disableBugDetectors= code- injection` in CLI mode; or when
173+ using Jest in ` .jazzerjsrc .json ` :
109174
110175` ` ` json
111- { " disableBugDetectors" : [" remote- code-execution " ] }
176+ { " disableBugDetectors" : [" code-injection " ] }
112177` ` `
113178
114179## Server-Side Request Forgery (SSRF)
0 commit comments