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

fix: check preconditions before running exploit code for the solidity bounty #126

Merged
merged 2 commits into from
Aug 6, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions tests/bounties/solidity-bounty/start.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,44 @@
#!/bin/sh

#
# Validate exploit code - Exploit code file must contain only ascii characters
#
grep -q "[^[:print:]]" $1
guidanoli marked this conversation as resolved.
Show resolved Hide resolved
status=$?
if [ $status -eq 0 ]; then
>&2 echo "Invalid exploit code: File contains non-ascii characters"
exit 1
fi
if [ $status -eq 2 ]; then
guidanoli marked this conversation as resolved.
Show resolved Hide resolved
>&2 echo "Invalid exploit code: Error reading the file"
exit 1
fi


#
# Validate exploit code - No experimental directives are allowed
#
grep -q "experimental" $1
status=$?
if [ $status -eq 0 ]; then
claudioantonio marked this conversation as resolved.
Show resolved Hide resolved
>&2 echo "Invalid exploit code: contains 'experimental' keyword"
exit 1
fi


#
# Validate exploit code - Requires specific version of Solidity
#
grep -q "pragma solidity 0.8.26" $1
claudioantonio marked this conversation as resolved.
Show resolved Hide resolved
status=$?
if [ $status -eq 1 ]; then
claudioantonio marked this conversation as resolved.
Show resolved Hide resolved
>&2 echo "Invalid exploit code: pragma solidity 0.8.26 not found"
exit 1
fi

#
# Run the exploit code
#
./solc $1
status=$?
# Status is always 139 when program crashes with "Segmentation fault" (SIGSEGV)
Expand Down