Skip to content

rugo/chacha20-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

Libsodium ChaCha20 Encryption Oracle

This code uses libsodium's ChaCha20 implementation to show that an attacker that can leak memory, can also leak the secret symetric key used.

The Vulnerable Service

To start the network service, you can use docker-compose:

cd stapelspass
docker-compose up -d

The service will then be build and deployed. It is now reachable on localhost, port 55432. A comfortable way to interact with it is by using netcat:

nc localhost 55432

The service uses a signed variable for indexing, which is a common cause for memory corruption bugs. Due to this bug it is possible to access stack elements above the intended region (e.g. the secret key leaked stored on the stack by libsodium).

The Exploit

To leverage the programs memory corruption into leaking the secret key and decrypting the given ciphertext, an exploit is prepared in exploit/decrypt.py. This exploit is written in Python and annotated. It requires the PyCryptoDome and Pwntools Python packages to be installed.

The requirements can be installed with (requires pip):

pip install -r exploit/requirements.txt

The exploit can be started with:

python3 decrypt.py localhost 55432

About

Libsodium ChaCha20 Encryption Oracle

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages