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

Bug report: Magic Function Holding #1190

Open
penwoodjon opened this issue Mar 29, 2021 · 0 comments
Open

Bug report: Magic Function Holding #1190

penwoodjon opened this issue Mar 29, 2021 · 0 comments
Labels

Comments

@penwoodjon
Copy link

penwoodjon commented Mar 29, 2021

Describe the bug
When running the Magic function on certain inputs, the function will hold indefinitely and use up compute resources, then at times errors out. This occurs in both the node package, and on the Github hosted browser version as well on Chrome.

To Reproduce

  1. Run the node chef.magic function with this input:
chef.magic('103.77.192[.]219\n104.140.114[.]110\n104.250.191[.]110\n108.61.246[.]56\n149.28.14[.]163\n157.230.221[.]198\n167.99.168[.]251\n185.250.151[.]72\n192.81.208[.]169\n203.160.69[.]66\n211.56.98[.]146\n5')

Expected behaviour
The function gives an output or errors out rather than holding.

Desktop:

  • OS: Mac OS Catalina
  • Browser: Node Package and Chrome
  • CyberChef version: 9.28.0

Additional context
I've found the source of the problem to be one of the regex test functions found in cyberchef/src/core/lib/Magic.mjs ln:45, specifically in this case the From Hexdump operation pattern check /^(?:(?:[\dA-F]{4,16}h?:?)?[ \t]*((?:[\dA-F]{2} ){1,8}(?:[ \t]|[\dA-F]{2}-)(?:[\dA-F]{2} ){1,8}|(?:[\dA-F]{4} )*[\dA-F]{4}|(?:[\dA-F]{2} )*[\dA-F]{2})[^\n]*\n?){2,}$/i.

If you are to run this regex directly on this input you get the same issue as this seems to be the source of the issue.

/^(?:(?:[\dA-F]{4,16}h?:?)?[ \t]*((?:[\dA-F]{2} ){1,8}(?:[ \t]|[\dA-F]{2}-)(?:[\dA-F]{2} ){1,8}|(?:[\dA-F]{4} )*[\dA-F]{4}|(?:[\dA-F]{2} )*[\dA-F]{2})[^\n]*\n?){2,}$/i.test('103.77.192[.]219\n104.140.114[.]110\n104.250.191[.]110\n108.61.246[.]56\n149.28.14[.]163\n157.230.221[.]198\n167.99.168[.]251\n185.250.151[.]72\n192.81.208[.]169\n203.160.69[.]66\n211.56.98[.]146\n5')

A potential solution could be changing this regex to be more efficient.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant