Build-time check to protect global variables from stack overflow
What changed, and why it matters
This commit adds a build-time safety check in the Ledger Bitcoin app's Makefile. It sets a minimum required stack size depending on the device (Nano X or other), which helps catch cases where too much memory is used globally and could overflow into the stack. It is a defensive hardening change, not a fix for a known active bug or attack.
Verify that APP_STACK_MIN_SIZE is actually consumed by a linker script, build script, or static-analysis tool elsewhere in the repository; otherwise the check may be inert. Treat as routine hardening, not an urgent vulnerability patch.
Security signals we found
Build-time stack-size guard introduced
References stack overflow risk in commit message
Device-specific stack limit constants added
Evidence from the diff
The Makefile now defines APP_STACK_MIN_SIZE as 8192 for TARGET_NANOX and 16384 otherwise. This value is intended to act as a build-time guard against global variables consuming so much RAM that the runtime stack has insufficient space, which could lead to stack overflow. The actual enforcement mechanism is not shown in this diff; it only declares the constant. The change is purely preventive and does not modify runtime code paths.
Changed components
Ledger Bitcoin app build configuration (Makefile)Inspect captured patch +10 / −0
diff --git a/Makefile b/Makefile
index 81b59d2..cb447ab 100644
--- a/Makefile
+++ b/Makefile
@@ -158,6 +158,16 @@ ENABLE_SWAP = 1
########################################
DEFINES += HAVE_BOLOS_APP_STACK_CANARY
+# Estimated maximum stack usage.
+# It acts as a build-time check to protect global variables.
+# On the Nano X, the stack size is limited to 8K at the OS level.
+ifeq ($(TARGET_NAME),TARGET_NANOX)
+ APP_STACK_MIN_SIZE := 8192
+else
+ APP_STACK_MIN_SIZE := 16384
+endif
+
+
# If set, the app will automatically approve all requests without user interaction. Useful for performance tests.
# It is critical that no such app is ever deployed in production.
AUTOAPPROVE_FOR_PERF_TESTS ?= 0
Why this scored 32/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.