Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Playground report a false postive in fuzz mode #682

Closed
fengkx opened this issue Dec 2, 2022 · 4 comments
Closed

Playground report a false postive in fuzz mode #682

fengkx opened this issue Dec 2, 2022 · 4 comments

Comments

@fengkx
Copy link

fengkx commented Dec 2, 2022

What is the problem?

Playground report a false postive in fuzz mode.

Here is the input regex

/(?=(<table))\1(?=(\s*))\2(?<tableAttrs>(?:(?![>])[^])*)(?=(>))\4(?<tableChildren>(?=((?:(?![<])[^])*))\6)(?=(<\/table>))\7/

image

Log:

parse: start
parse: finish
  pattern: /(?=(<table))\1(?=(\s*))\2(?<tableAttrs>(?:(?![>])[^])*)(?=(>))\4(?<tableChildren>(?=((?:(?![<])[^])*))\6)(?=(<\/table>))\7/
fuzz: start (usesAcceleration: false)
fuzz: seeding start (seeder: static)
automaton: EpsNFA construction
     state size: 143
  alphabet size: 10
automaton: OrderedNFA construction
     state size: 39
  alphabet size: 10
fuzz: seeding finish
  size: 260
fuzz: iteration 1
  traces: 100
     max: '<table>\t<' (steps: 29, rate: 3.2222222222222223)
fuzz: attack start (status: limit)
  string: '/' + '<table'.repeat(168) + '<>'.repeat(159) + '<'
fuzz: attack (exponential)
fuzz: attack (polynomial: 4)
fuzz: attack succeeded (status: timeout)
  string: '/' + '<table'.repeat(269) + '<>'.repeat(260) + '<'
recall: code
const re = new RegExp('(?=(<table))\\1(?=(\\s*))\\2(?<tableAttrs>(?:(?![>])[^])*)(?=(>))\\4(?<tableChildren>(?=((?:(?![<])[^])*))\\6)(?=(<\\/table>))\\7', '');
const input = '/' + '<table'.repeat(269) + '<>'.repeat(260) + '<';
const start = Date.now();
re.exec(input);
const end = Date.now();
console.log(Number(end - start).toString());

Run recall code:
image
It seems cost 2ms to run instead of 2s

@makenowjust
Copy link
Contributor

makenowjust commented Dec 2, 2022

The recall phase does not work on the playground (browser) because it needs to spawn a process.

@fengkx
Copy link
Author

fengkx commented Dec 2, 2022

The recall phase does not work on the playground (browser) because it needs to spawn a process.

Try run on node.js with RECHECK_BACKEND=native it still report a fuzz vulnerable result. But when I ran the recall code ouput, it takes 16ms to run. I expect it need a longer time to run?

@makenowjust
Copy link
Contributor

Please set recallTimeout explicitly (e.g. check('...', '', { recallTimeout: 2000 })).

@fengkx
Copy link
Author

fengkx commented Dec 2, 2022

Thanks, that means I need a longer recallTimeout to generate a longer attack string. This library is awesome~

@fengkx fengkx closed this as completed Dec 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants