|
1 |
| -This is a proof-of-concept of exfiltrating secrets from a developer's laptop. |
2 |
| -When `innocent_app` is opened in VSCode, for example, the editor runs enough |
3 |
| -of the Rust toolchain to expand the nefarious `make_answer!` macro, which opens |
4 |
| -`.ssh/id_rsa` and sends its contents to `localhost:8080`. |
| 1 | +# TL;DR |
| 2 | + |
| 3 | +Open `innocent_app` in [VSCode](https://code.visualstudio.com/)*, and the |
| 4 | +contents of your `.ssh/id_rsa` file will be sent over TCP to |
| 5 | +`localhost:8080`. **You don't even need to open any files in the project!** |
| 6 | + |
| 7 | +*This assumes you have the rust toolchain available on your machine, and the |
| 8 | +[rust-analyzer](https://marketplace.visualstudio.com/items?itemName=matklad.rust-analyzer) |
| 9 | +VSCode plugin. |
| 10 | + |
| 11 | +# Exfiltrating secrets with Rust macros |
| 12 | + |
| 13 | +This is a proof-of-concept of exfiltrating secrets from a developer's machine. |
| 14 | +Originally, the target was exfiltrate at compile-time, but it became apparent it |
| 15 | +was possible even before that step, i.e. during pre-processing. |
5 | 16 |
|
6 |
| -**This shows a trivial example of exfiltrating secrets just by the developer |
7 |
| -opening up the source code in an editor.** |
| 17 | +## How it works |
8 | 18 |
|
9 |
| -To test: |
| 19 | +When `innocent_app` is opened in VSCode, the editor runs enough of the Rust |
| 20 | +toolchain to expand the nefarious `make_answer!` macro, which opens |
| 21 | +`.ssh/id_rsa` and sends its contents to `localhost:8080`. |
| 22 | + |
| 23 | +# Run it yourself |
10 | 24 |
|
11 |
| - * Listen on port 8080 locally, for example with `nc -lk 8080` |
12 |
| - * Open up the `innocent_app` in VSCode\* (other editors currently untested) |
| 25 | +* Clone this repo: `git clone https://github.com/lucky/bad_actor_poc.git` |
| 26 | +* Listen on port 8080 locally, for example with `nc -lk 8080` |
| 27 | +* Open up the `innocent_app` in VSCode with rust-analyzer plugin |
13 | 28 |
|
14 | 29 | Once open, VSCode will analyze and index the code, including the expansion of
|
15 | 30 | macros, then you should see the contents of your `.ssh/id_rsa` private key in
|
16 | 31 | the `nc` window.
|
17 | 32 |
|
18 |
| -*This assumes you have the rust toolchain available on your machine. |
| 33 | +You can trigger the same behavior at compile-time by running `cargo build` |
| 34 | +in the `innocent_app` directory. |
| 35 | + |
| 36 | +## Notes |
| 37 | + |
| 38 | +**This may affect other editors.** VSCode and rust-analyzer were used to confirm |
| 39 | +the attack vector, but are not exactly responsible for them. Any editor that |
| 40 | +expands a proc macro can do this. |
| 41 | + |
| 42 | +**There may be similar attacks for other languages.** For example, it may be |
| 43 | +possible to attack Java annotation processing. |
0 commit comments