In which languages is it a security hole to use user-supplied regular expression?

后端 未结 8 1480
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-17 17:00

Edit: tchrist has informed me that my original accusations about Perl\'s insecurity are unfounded. However, the question still stands.

I know that i

相关标签:
8条回答
  • 2020-12-17 17:29

    1)Vulnerabilities are found in regex libraries, such as this buffer overflow that affects Webkit and allows any attacker to gain remote code execution by accessing the regex library from javascript.

    2)It is a DoS condition in C#.

    3)User supplied regex's can be for php because of modifiers. Adding the /e modifier evals the match. In this case system will be eval()'ed.

    preg_replace("/.*/e","system('echo /etc/passwd')");

    Or in the form of a vulnerability:

    preg_replace($_GET['regex'],$_GET['check']);

    0 讨论(0)
  • 2020-12-17 17:29

    AFAIK, you can do it safely in C#: you can supply the regex string to the Regex constructor, and if it fails to parse it'll throw. I'm not sure about others.

    0 讨论(0)
提交回复
热议问题