fix(safe_sleep): assert arg is int to block code-injection#4148
Open
Rudxain wants to merge 1 commit intoactions:mainfrom
Open
fix(safe_sleep): assert arg is int to block code-injection#4148Rudxain wants to merge 1 commit intoactions:mainfrom
Rudxain wants to merge 1 commit intoactions:mainfrom
Conversation
This blocks code-injection
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses a dormant code injection vulnerability in the safe_sleep.sh script by adding integer validation for the time interval argument before it's used in potentially vulnerable shell commands.
Key changes:
- Adds input validation using
printf %dto ensure the argument is an integer before use - Provides a clear error message when invalid input is detected
Comment on lines
+9
to
+13
| # assert integer | ||
| if ! builtin printf %d "$1" &>/dev/null; then | ||
| echo "safe_sleep: invalid time interval ‘$1’" | ||
| exit 1 | ||
| fi |
There was a problem hiding this comment.
This security fix lacks test coverage. Given that this addresses a code injection vulnerability, tests should be added to verify that the script correctly rejects malicious inputs (e.g., strings with shell metacharacters, command substitutions) and accepts valid integer inputs. The repository has comprehensive test coverage in the Test/L0 directory for other components.
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.
I've implemented the fix mentioned here.
The (currently dormant) vulnerability was introduced by 2 PRs:
The assertion doesn't exit if the integer is signed (negative), but I assume that's not a problem for
pingandread