-
Notifications
You must be signed in to change notification settings - Fork 10
fix: improve one-shot token library copy robustness in chroot mode #606
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -169,14 +169,24 @@ if [ "${AWF_CHROOT_ENABLED}" = "true" ]; then | |
|
|
||
| # Copy one-shot-token library to host filesystem for LD_PRELOAD in chroot | ||
| # This prevents tokens from being read multiple times by malicious code | ||
| # Note: /tmp is always writable in chroot mode (mounted from host /tmp as rw) | ||
| ONE_SHOT_TOKEN_LIB="" | ||
| if [ -f /usr/local/lib/one-shot-token.so ]; then | ||
| mkdir -p /host/tmp/awf-lib | ||
| if cp /usr/local/lib/one-shot-token.so /host/tmp/awf-lib/one-shot-token.so 2>/dev/null; then | ||
| ONE_SHOT_TOKEN_LIB="/tmp/awf-lib/one-shot-token.so" | ||
| echo "[entrypoint] One-shot token library copied to chroot at ${ONE_SHOT_TOKEN_LIB}" | ||
| # Create the library directory in /tmp (always writable) | ||
| if mkdir -p /host/tmp/awf-lib 2>/dev/null; then | ||
| # Copy the library and verify it exists after copying | ||
| if cp /usr/local/lib/one-shot-token.so /host/tmp/awf-lib/one-shot-token.so 2>/dev/null && \ | ||
| [ -f /host/tmp/awf-lib/one-shot-token.so ]; then | ||
| ONE_SHOT_TOKEN_LIB="/tmp/awf-lib/one-shot-token.so" | ||
| echo "[entrypoint] One-shot token library copied to chroot at ${ONE_SHOT_TOKEN_LIB}" | ||
| else | ||
| echo "[entrypoint][WARN] Could not copy one-shot-token library to /tmp/awf-lib" | ||
| echo "[entrypoint][WARN] Token protection will be disabled (tokens may be readable multiple times)" | ||
| fi | ||
| else | ||
| echo "[entrypoint][WARN] Could not copy one-shot-token library to chroot" | ||
| echo "[entrypoint][ERROR] Could not create /tmp/awf-lib directory" | ||
| echo "[entrypoint][ERROR] This should not happen - /tmp is mounted read-write in chroot mode" | ||
|
Comment on lines
+187
to
+188
|
||
| echo "[entrypoint][WARN] Token protection will be disabled (tokens may be readable multiple times)" | ||
| fi | ||
| fi | ||
|
|
||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The mkdir/cp failures are redirected to /dev/null, so the warnings/errors here won’t include the underlying reason (e.g., permission denied, ENOSPC). For the “improved diagnostics” goal, consider capturing stderr and including it in the log output (or at least logging it when the operation fails).