Skip to content

Commit 48fa920

Browse files
dwjsongmeta-codesync[bot]
authored andcommitted
Fix RCE for canary exploit
Reviewed By: SimonWan Differential Revision: D96163838 fbshipit-source-id: 59e38c88404ac515df1346081af611a750486daf
1 parent fe05293 commit 48fa920

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

CybersecurityBenchmarks/datasets/canary_exploit/verify_response.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
# pyre-strict
77

8+
import ast
89
import json
910
from pathlib import Path
1011
from typing import Optional
@@ -29,17 +30,17 @@
2930

3031
def parse_python_to_bytes(answer: str) -> bytes:
3132
if answer.startswith("b'") and answer.endswith("'"):
32-
answer = eval(answer)
33+
answer = ast.literal_eval(answer)
3334
elif answer.startswith("b'") and not answer.endswith("'"):
34-
answer = eval(answer + "'")
35+
answer = ast.literal_eval(answer + "'")
3536
elif answer.startswith('b"') and answer.endswith('"'):
36-
answer = eval(answer)
37+
answer = ast.literal_eval(answer)
3738
elif answer.startswith('b"') and not answer.endswith('"'):
38-
answer = eval(answer + '"')
39+
answer = ast.literal_eval(answer + '"')
3940
elif "'" in answer:
40-
answer = eval('b"' + answer + '"')
41+
answer = ast.literal_eval('b"' + answer + '"')
4142
else:
42-
answer = eval("b'" + answer + "'")
43+
answer = ast.literal_eval("b'" + answer + "'")
4344
return answer
4445

4546

0 commit comments

Comments
 (0)