#include "/dev/random" #2582
Labels
conclusion: off topic
Off topic for this repository
topic: build-process
Related to the sketch build process
type: imperfection
Perceived defect in any part of project
Describe the problem
If you include /dev/random, /etc/passwd or any other system file, gcc will happily include it, leading to all sorts of consequences
To reproduce
1- Install the arduino AVR core
2- Create a test sketch
3- Put this thing in the .ino file:
4- Compile with:
5- Output:
Expected behavior
This is actually what is expected out of GCC, but if you're running a cloud compiling service, it will mean your system is vulnerable to being taken down by #include "/dev/random" , for example. For example: on Google Cloud Run, this causes a container with the compiler to use up all its available memory and die.
Without making any change to arduino-cli itself, is it possible to sandbox the compile so that it has no access to the file system outside of the libraries directory? I'm assuming there's a linuxy way of doing this, but I'm not that good at linux.
Adding a "include filtering phase" before or after the library detection phase would probably fix it. In what section of the source code could this be implemented?
Arduino CLI version
arduino-cli Version: nightly-20240412 Commit: 2d66dfa Date: 2024-04-12T01:27:41Z
Operating system
Linux
Operating system version
Linux DESKTOP-ACP0IT4 5.15.146.1-microsoft-standard-WSL2 #1 SMP Thu Jan 11 04:09:03 UTC 2024 x86_64 GNU/Linux
Additional context
No response
Issue checklist
The text was updated successfully, but these errors were encountered: