Repository navigation
fix(logging): redact and sanitize execution errors before logging - #1464
Merged
Merged
Conversation
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
bashkit | 4b7d0fb | Commit Preview URL | Apr 25 2026, 02:19 AM |
chaliy
force-pushed
the
2026-04-24-propose-fix-for-logging-vulnerability
branch
from
April 25, 2026 02:19
715738d to
4b7d0fb
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
chaliy
added a commit
that referenced
this pull request
May 30, 2026
) ### Motivation - Prevent leaking untrusted script data and log-injection via execution error logs which previously logged raw `Error` strings. - Ensure execution-failure messages go through the same `LogConfig` redaction and sanitization used elsewhere. ### Description - Add `format_error_for_log(error, &LogConfig)` in `crates/bashkit/src/logging_impl.rs` that sanitizes control/newline chars, applies `redact_value`, detects embedded secret-like tokens and aggressively redacts, and truncates long values per config. - Re-export the new formatter via `bashkit::logging` and wire `Bash::exec_impl` to call `logging::format_error_for_log` before emitting the `tracing::error!` entry. - Add a regression unit test `test_error_message_redacted_and_sanitized` that verifies a grep-style error containing an API-key-like token plus a forged newline is redacted. ### Testing - Ran the focused unit test `cargo test -p bashkit --features logging test_error_message_redacted_and_sanitized` which failed on the unsafe code path before the fix and passes after the change. - Ran the logging security test suite `cargo test -p bashkit --features logging --test logging_security_tests` and all tests passed (26 passed, 0 failed). - Ran `cargo fmt --check` and formatting check passed. ------ [Codex Task](https://chatgpt.com/codex/cloud/tasks/task_e_69eaeee6fd50832bbb663a72bf26efa9)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Errorstrings.LogConfigredaction and sanitization used elsewhere.Description
format_error_for_log(error, &LogConfig)incrates/bashkit/src/logging_impl.rsthat sanitizes control/newline chars, appliesredact_value, detects embedded secret-like tokens and aggressively redacts, and truncates long values per config.bashkit::loggingand wireBash::exec_implto calllogging::format_error_for_logbefore emitting thetracing::error!entry.test_error_message_redacted_and_sanitizedthat verifies a grep-style error containing an API-key-like token plus a forged newline is redacted.Testing
cargo test -p bashkit --features logging test_error_message_redacted_and_sanitizedwhich failed on the unsafe code path before the fix and passes after the change.cargo test -p bashkit --features logging --test logging_security_testsand all tests passed (26 passed, 0 failed).cargo fmt --checkand formatting check passed.Codex Task