Bypass regex with global flag
When a target uses a global regex (/g flag) to validate user input, try sending a large string with a disallowed character at the end to offset the lastIndex property. Then, send a second payload with the malicious input, which may be processed without being blocked by the regex. This can be used to bypass input validation and potentially inject malicious code. For example, if the target uses const re = /<|>|\s/g to block HTML tags, send a string like AAAAAAAAAAAAAAAAAAAAAAAAA< followed by the malicious payload. The regex will start searching from the offset position and may miss the injected code.
Follow #challenge, #ctf or #xss for new tips like this one, on your notifications page and, if you choose, in a daily or weekly email.
Comments
No comments yet.