-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Trying to get in touch regarding a security issue #36108
Comments
cc @ampproject/wg-security-privacy |
@molnarg fyi |
@coreymasanto @newmuis @alanorozco Reported a security issue in huntr https://www.huntr.dev/bounties/36577e6a-67e2-4002-9586-007bdf8407d9/ long back, can you please validate this? amphtml/src/core/types/string/index.js Line 92 in 3fe2ae4
|
Hi @ready-research: That regex shouldn't be vulnerable. The const regex = /\${([^}]*)}/;
function test(length) {
const str = '${' + 'a'.repeat(length);
const now = performance.now();
regex.test(str);
return performance.now() - now;
}
for (let i = 0; i < 500; i++) {
console.log({ length: i, time: test(i) });
} |
@jridgewell Here is the POC
Check the Output:
|
Ok, so this is the replace iterating until the end of the string, doesn't match, goes to next Thankfully, this is pretty slow increase and requires an extremely large string. We could add |
Yeah, agrees with you it requires an extremely large string. Security is all about edge cases. So can you please raise a PR for this? |
If the input string contains many `${` which do not have a closing `}`, the `expandTemplate`'s replace will iterate the entire string at every beginning mark. Fixes ampproject#36108.
@jridgewell Tested the above fix, I can confirm that this resolves the issue. Thanks for the quick response. Can you please mark this huntr report |
If the input string contains many `${` which do not have a closing `}`, the `expandTemplate`'s replace will iterate the entire string at every beginning mark. Fixes ampproject#36108.
If the input string contains many `${` which do not have a closing `}`, the `expandTemplate`'s replace will iterate the entire string at every beginning mark. Fixes ampproject#36108.
If the input string contains many `${` which do not have a closing `}`, the `expandTemplate`'s replace will iterate the entire string at every beginning mark. Fixes ampproject#36108.
If the input string contains many `${` which do not have a closing `}`, the `expandTemplate`'s replace will iterate the entire string at every beginning mark. Fixes #36108.
@jridgewell - thanks for your support here ❤️ Are you able to mark the report as fixed? You just need the commit SHA from the merge and the patched version. You are welcome to take the reward for fixing it too! |
Is it possible to send the reward to @ready-research? I'm explicitly disallowed from taking contributions for work. |
@jridgewell - we can only reward fixes to researchers if they submit patches via the report page. If you are not able to self-reward, you can select |
Just for your reference @jridgewell: |
Hey there!
I'd like to report a security issue but cannot find contact instructions on your repository.
If not a hassle, might you kindly add a
SECURITY.md
file with an email, or another contact method? GitHub recommends this best practice to ensure security issues are responsibly disclosed, and it would serve as a simple instruction for security researchers in the future.Thank you for your consideration, and I look forward to hearing from you!
(cc @huntr-helper)
The text was updated successfully, but these errors were encountered: