-
Notifications
You must be signed in to change notification settings - Fork 1
fix(log_sanitise): improved sanitization logic #54
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
fix(log_sanitise): improved sanitization logic #54
Conversation
GingerGraham
commented
Feb 6, 2026
- address [BUG] Recommended Fixes #52
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.
Pull request overview
This PR addresses issue #52 by tightening log-message sanitization so newline handling and ANSI escape stripping are controlled independently, and by refining the fallback ANSI escape stripping pattern.
Changes:
- Update
_sanitize_log_messageso enablingLOG_UNSAFE_ALLOW_NEWLINESno longer short-circuits other sanitization steps. - Adjust
_strip_ansi_codesfallback stripping regex and add explanatory comments.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Graham Watts <34165628+GingerGraham@users.noreply.github.com>
|
@copilot open a new pull request to apply changes based on the comments in this thread |
|
@GingerGraham I've opened a new pull request, #55, to work on those changes. Once the pull request is ready, I'll request review from you. |
…SI regex Co-authored-by: GingerGraham <34165628+GingerGraham@users.noreply.github.com>
…omment Co-authored-by: GingerGraham <34165628+GingerGraham@users.noreply.github.com>
Co-authored-by: GingerGraham <34165628+GingerGraham@users.noreply.github.com>
Co-authored-by: GingerGraham <34165628+GingerGraham@users.noreply.github.com>
fix(sanitization): close security gaps in ANSI escape sequence stripping
- addresses comments left on #54 - adds regression tests for ansi attack handling - improves ansi sanitisation logic
…d-fixes-02 Signed-off-by: Graham Watts <34165628+GingerGraham@users.noreply.github.com>
BREAKING CHANGE: changes behaviour for messages passed to the logger and so revving to v2.x * feat: enhance logging sanitization - Introduced a comprehensive security review document for the bash-logger library, detailing vulnerabilities and recommendations. - Implemented input sanitization to prevent log injection via newline, carriage return, and tab characters. - Added a configuration option to allow unsafe logging of newlines, with appropriate warnings and documentation. - Enhanced tests to cover new functionality related to unsafe logging and input sanitization. - Updated troubleshooting documentation to reflect changes in newline handling and logging behavior. - Included security research findings from 2026-02-04 for evidence - fixes #35 * feat: implement ANSI code injection protection and update documentation - fixes #36 * feat: add TOCTOU race condition protection during log file creation and enhance related tests * feat: add script name sanitization to prevent shell metacharacter injection - fixes #39 * feat: add configurable log line length limits to prevent DoS attacks - fixes #41 * Update logging.sh Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Graham Watts <34165628+GingerGraham@users.noreply.github.com> * fix(logging): improved TOCTOU risk mitigation and error messaging - addresses suggestions from #49 - fixes part of #52 - also updated Makefile to provide for parallel processing of linting * fix(log_sanitise): improved sanitization logic - address #52 * Update logging.sh Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Graham Watts <34165628+GingerGraham@users.noreply.github.com> * Initial plan * fix(sanitization): handle ST-terminated OSC, DEC modes, and improve CSI regex Co-authored-by: GingerGraham <34165628+GingerGraham@users.noreply.github.com> * fix(sanitization): handle embedded escapes in OSC sequences and fix comment Co-authored-by: GingerGraham <34165628+GingerGraham@users.noreply.github.com> * fix(sanitization): prevent greedy matching across multiple OSC sequences Co-authored-by: GingerGraham <34165628+GingerGraham@users.noreply.github.com> * docs(sanitization): improve comment clarity for OSC pattern matching Co-authored-by: GingerGraham <34165628+GingerGraham@users.noreply.github.com> * fix: addressing PR comments - addresses comments left on #54 - adds regression tests for ansi attack handling - improves ansi sanitisation logic * Update docs/sensitive-data.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Graham Watts <34165628+GingerGraham@users.noreply.github.com> * Update demo-scripts/demo_unsafe_newlines.sh Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Graham Watts <34165628+GingerGraham@users.noreply.github.com> * Update demo-scripts/demo_ansi_protection.sh Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Graham Watts <34165628+GingerGraham@users.noreply.github.com> * Update logging.sh Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Graham Watts <34165628+GingerGraham@users.noreply.github.com> * Update tests/test_ansi_injection.sh Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Graham Watts <34165628+GingerGraham@users.noreply.github.com> * chore: refactor demo and test scripts for clarity and consistency * Update docs/configuration.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Graham Watts <34165628+GingerGraham@users.noreply.github.com> * docs: adding unsafe_allow_ansi_codes * docs: updating security policy supported versions --------- Signed-off-by: Graham Watts <34165628+GingerGraham@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
## [2.0.0](1.3.0...2.0.0) (2026-02-09) ### ⚠ BREAKING CHANGES * changes behaviour for messages passed to the logger and so revving to v2.x * feat: enhance logging sanitization - Introduced a comprehensive security review document for the bash-logger library, detailing vulnerabilities and recommendations. - Implemented input sanitization to prevent log injection via newline, carriage return, and tab characters. - Added a configuration option to allow unsafe logging of newlines, with appropriate warnings and documentation. - Enhanced tests to cover new functionality related to unsafe logging and input sanitization. - Updated troubleshooting documentation to reflect changes in newline handling and logging behavior. - Included security research findings from 2026-02-04 for evidence ### Features * adding defensive programming and bug fixes ([#56](#56)) ([62b717a](62b717a)), closes [#35](#35) [#36](#36) [#39](#39) [#41](#41) [#49](#49) [#52](#52) [#52](#52) [#54](#54) * **ref:** primary git message ([a0a7a09](a0a7a09)) ### Documentation * adding download tracking ([001f03b](001f03b))