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

Detect Malicious STL files #10

Open
maltfield opened this issue Jul 24, 2024 · 13 comments
Open

Detect Malicious STL files #10

maltfield opened this issue Jul 24, 2024 · 13 comments
Assignees

Comments

@maltfield
Copy link
Member

maltfield commented Jul 24, 2024

This issue will track the effort to implement some mechanism to scan (or sanitize) .stl files committed in PRs

Problem

Today @goldfishlaser and I realized that we don't have a system in-place to be able to scan and/or sanitize .stl changes committed by contributors. For example, this simple PR resulted in a change to an .stl file with 39,614 additions and 39,726 deletions

39,614 additions, 39,726 deletions not shown because the diff is too large

The concern is not unfounded: there has been at least one historically-known vulnerability where a maliciously-crafted .stl file could be used to trigger a heap buffer overflow. This was identified as a HIGH severity (8.8/10) bug by NIST in CVE-2022-38072

Solution

We need either:

  1. some way to scan .stl files, or
  2. some way to sanitize .stl files (eg something like qvm-convert or Dangerzone), or
  3. we need to have a policy not to accept .stl files into this repo (perhaps we can use a CI process to generate them from the source .scad files?)
  4. something else that adequately mitigates this risk
@maltfield maltfield self-assigned this Jul 24, 2024
@maltfield
Copy link
Member Author

maltfield commented Jul 24, 2024

Here's an example real-world file change (taken from the PR mentioned in the OP)

wget -O pre.stl https://raw.githubusercontent.com/BusKill/usb-a-magnetic-breakaway/master/Goldfishlaser%20Version/CAD%20Files/intermediary%20design%20files/usbamagb_v04.0.stl
wget -O post.stl https://raw.githubusercontent.com/goldfishlaser/usb-a-magnetic-breakaway/ee7b7862f07bda4b132e177e7807fb50050db464/Goldfishlaser%20Version/CAD%20Files/intermediary%20design%20files/usbamagb_v04.0.stl

diff pre.stl post.stl

The good news is that the .stl file is just a plaintext file, but the bad news is that the diff is >100,000 lines long. The actual number of lines changed is almost 50,000.

user@disp2114:~$ file pre.stl 
pre.stl: ASCII text
user@disp2114:~$ 

user@disp2114:~$ file post.stl 
post.stl: ASCII text
user@disp2114:~$ 

user@disp2114:~$ diff pre.stl post.stl | wc -l
106982
user@disp2114:~$ 

user@disp2114:~$ diff -y --suppress-common-lines pre.stl post.stl | wc -l
44661
user@disp2114:~$ 

@maltfield
Copy link
Member Author

I created this question on SE to see if there's already a tool available to scan or sanitize .stl files

@maltfield
Copy link
Member Author

I opened a feature request for Dangerzone to support .stl files:

@maltfield
Copy link
Member Author

maltfield commented Jul 25, 2024

I read the TALOS-2022-1594 report published in April 2023 that describes the heap buffer overflow vulnerability in ADMesh v0.98.4 due to a maliciously-crafted .stl file, but unfortunately they didn't publish an example of the .stl file.

I'm curious if this issue can only be caused by binary files, so maybe it's sufficiently mitigated by only accepting plaintext .stl files?

Or maybe the maliciously-crafted .stl file doesn't comply with the STL syntax, such that we can greatly reduce our risk by simply doing a syntax check on a plaintext .stl file (refusing to merge if there's errors)?

I asked Talos and the ADMesh dev to please publish the maliciously-crafted .stl file, so that we could study it

@maltfield
Copy link
Member Author

@maltfield
Copy link
Member Author

@maltfield
Copy link
Member Author

@goldfishlaser
Copy link
Member

goldfishlaser commented Aug 29, 2024

See https://doi.org/10.1145/3471621.3471843

Edit: they mention a follow up paper and I found it but its not free: https://doi.org/10.1145/3626232.3653276

@maltfield
Copy link
Member Author

maltfield commented Aug 29, 2024

Interesting. Quick review of the linked file above describes methods of using .stl files as a means to in/exfiltrate data with (encrypted) steganographic data encoded inside of objects. They describe use-cases of "watermarking" 3D IP. Blech.

Anyway, the relevant bit that I see is their Three Contexts of Distinguishability and Robustness Against STL File Sanitation sections, where they talk about how to sanitize STL files.

each and any of these can determine a defender’s ability to detect the subliminal steganographic channel and even extract the encoded message for further analysis. Such detection is critical for follow-on security procedure...
...
With the proposed bit encoding scheme, the “sanitization” of STL files is fairly simple and straightforward. Defenders can overwrite all facets in the file with either the same value (0 or 1) or with a completely random value. As mentioned before, due to the semantic equivalency of the vertex cyclical rotation, it should not affect the described 3D object geometry. However, while theoretically sound, this assumption needs to be verified empirically; we plan to conduct such an investigation in a follow-up work. Consequently, the proposed approach is fragile, and can be easily disrupted by the described sanitation approach.

We should note, however, that alternative encoding techniques are possible (see Appendix A.1). Similar to distinguishability, each of these encoding techniques would require a different sanitation approach. Any technique meeting the same criteria as our selected encoding, non-interference with printed geometry, would exhibit the same level of fragility against sanitation.

Alternatively, incoming and outgoing STL files can be read into a CAD program and re-saved, assuming that this step will remove all possible steganographically encoded information, regardless of the encoding primitives used. However, if such a CAD program is trojanized, it can be used by a malicious actor for the encoding of secret information instead of removing it.

@maltfield
Copy link
Member Author

maltfield commented Aug 29, 2024

@goldfishlaser I think an STL sanitizer would make a great tool to present at DEF CON :P

@goldfishlaser
Copy link
Member

I don't disagree. Their paper was pretty entertaining.

@goldfishlaser
Copy link
Member

I plan to get my next free ticket by becoming a goon though :P

@goldfishlaser
Copy link
Member

goldfishlaser commented Aug 29, 2024 via email

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

No branches or pull requests

2 participants