Skip to content

Commit 83f5152

Browse files
committed
add license, update readme
1 parent 25c15f2 commit 83f5152

File tree

2 files changed

+42
-10
lines changed

2 files changed

+42
-10
lines changed

LICENSE

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Copyright 2021 Jared Harper
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4+
5+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6+
7+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

+35-10
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,43 @@
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.
516

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
818

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
1024

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
1328

1429
Once open, VSCode will analyze and index the code, including the expansion of
1530
macros, then you should see the contents of your `.ssh/id_rsa` private key in
1631
the `nc` window.
1732

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

Comments
 (0)