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

Aliencodex #89

Merged
merged 12 commits into from
Oct 12, 2018
Merged

Aliencodex #89

merged 12 commits into from
Oct 12, 2018

Conversation

nczhu
Copy link
Contributor

@nczhu nczhu commented Oct 11, 2018

LEVEL idea:

This level exploits the fact that the EVM doesn't validate an array's ABI-encoded length vs its actual payload. Additionally, it exploits the arithmetic underflow of array length, by expanding the array's bounds to the entire storage area of 2^256. The user is then able to modify all contract storage.

The narrative is that you have to 1. make contact with this Alien contract to access the Codex for an Alien race. 2. Upon making contact, you can manipulate the Codex and gain ownership of entire Alien contract.
😂

This lvl addresses @ajsantander 's #19 and #22 , two issues from Underhanded 2017
Let me know what you think and suggestions to improve upon it. Thanks so much!

Copy link
Contributor

@0age 0age left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two for the price of one! Very cool concept and good execution. Take a look at my comments and let me know your take on the suggestions.

_;
}

function make_contact(bytes32[] _impossible_message) public {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems as though _impossible_message gives it away a touch - what if you named it something in keeping with the awesome theme, like _firstContactMessage, or you could emphasize that the message has to be big and important with something like _momentousMessage?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_firstContactMessage is much better. Changed - thanks!

contact = true;
}

function push(bytes32 _content) contacted public {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could use some function names with more gravitas here too - push, pop, edit sort of suggest that there's an array that needs to be manipulated, whereas record, retract, revise (or whatever you think is cool) make me think "Ok, I'm really interacting with an alien codex here".

@@ -0,0 +1,6 @@
Claim ownership of the Alien contract to complete this level.

TODO
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might want to mention of the underhanded coding contest here (without linking to the winners 😄) to give a small nudge to the answer. Your call!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the hint 😂

it('codex array should underflow, giving user all storage access to become owner', async function() {

await instance.pop();
let _data = `0xe537637d4ef1d2ad89edf8c4d91132028e8195cdf30bb4b5053d4f8cd260341d4805f30a000000000000000000000001`+ player.substr(2);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think it would be doable to use the contract interface for this rather than a raw transaction?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possible for us to keep the raw trx? 😄Hoping most players solve this lvl with console/command line, without using an attack contract or Remix.

For better readability, I refactored the _data bytecode and added comments

@nczhu
Copy link
Contributor Author

nczhu commented Oct 12, 2018

Thank you for the review @0age !

I've revised per your feedback. Happy to iterate further - thanks again

Copy link
Contributor

@0age 0age left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Love the level!

@theethernaut theethernaut merged commit 6641cf7 into OpenZeppelin:master Oct 12, 2018
@theethernaut
Copy link
Contributor

Level is live!
https://ethernaut.zeppelin.solutions/level/0x73048cec9010e92c298b016966bde1cc47299df5

Awesome @nczhu !!

@theethernaut
Copy link
Contributor

BTW, I'd suggest that you try the level in the official ethernaut dapp. I think there might be a problem with the gas limit you entered in gamedata.json. Try manually setting a large gas amount in metamask, and then put that in gamedata.json.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants