+
Skip to content

Keep an incremental count of open block types #471

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

Closed

Conversation

kevinbackhouse
Copy link

@kevinbackhouse kevinbackhouse commented Apr 1, 2023

This is a rebase of the solution that we implemented in cmark-gfm to fix GHSA-66g8-4hjf-77xh.

The idea is to incrementally keep an up-to-date count of the number of "open" blocks, categorized by node type, so that the loop in check_open_blocks can bail out early when it can see from the counts that the rest of the list doesn't contain any nodes that need to be checked.

I've fuzzed this solution extensively on cmark-gfm, but not on cmark.

Reproduction steps for the bug that this PR fixes:

python3 -c 'n = 10000; print(" -" * n + "x" + "\n" * n)' | cmark

Increasing the number 10000 in the above command causes the running time to increase quadratically.

@kevinbackhouse
Copy link
Author

Out of interest, I'm surprised that the checks ran automatically. I'm a first-time contributor to cmark, so normally would have to wait for approval to run the checks. Have you modified something in the settings to allow the checks to run for first-time contributors?

@nwellnhof
Copy link
Contributor

This fix is incomplete. Please don't merge yet.

@kevinbackhouse See my report at HackerOne.

@jgm
Copy link
Member

jgm commented Apr 2, 2023

Yes, I've modified the settings so that no approval is needed except for new GH-ers.

@kevinbackhouse
Copy link
Author

I haven't seen the HackerOne report yet (I'm not on the team that has access), but I've independently figured out what the problem is. I think it means that this strategy of counting the number of open blocks won't work, and we have to go back to the original solution of putting an arbitrary limit on the nesting depth.

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

Successfully merging this pull request may close these issues.

3 participants
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载