[AppSecAI Agent] Uncontrolled command line - #2
Open
conviso-platform-appsec[bot] wants to merge 1 commit into
Open
[AppSecAI Agent] Uncontrolled command line#2conviso-platform-appsec[bot] wants to merge 1 commit into
conviso-platform-appsec[bot] wants to merge 1 commit into
Conversation
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.
AppSecAI Agent
Issue ID: 8860292
Title: Uncontrolled command line
Severity: CRITICAL
Type: SastFinding
Description
Using externally controlled strings in a command line is vulnerable to malicious changes in the strings.
Code that passes user input directly to
Runtime.exec, or some other library routine that executes a command, allows the user to execute malicious code.Fix Details
Security Fix: Uncontrolled Command Line Injection in
lerArquivoMethodVulnerability
The
lerArquivomethod inArquivoServiceImplwas vulnerable to OS Command Injection (CWE-78). The method accepted a user-controllednomeparameter and passed it directly into a shell command viaRuntime.exec:Because the
nomeparameter was concatenated directly into a shell command string executed withsh -c, an attacker could inject arbitrary shell commands. For example, passingnomeas"/etc/passwd; rm -rf /"would execute bothcat /etc/passwdandrm -rf /.Fix
The fix eliminates the use of
Runtime.execentirely and replaces it with Java's built-in NIOFiles.readAllBytesAPI, which reads file contents safely without invoking a shell:Runtime.execusage: The shell command execution (sh -c cat <nome>) has been completely removed.Files.readAllBytes(Path)is used instead, which does not involve any shell interpretation.Paths.get(nome).normalize()and validated against a whitelist regex pattern ([a-zA-Z0-9_.\-/\\: ]+) to reject paths containing shell metacharacters or other dangerous characters.SecurityExceptionfor invalid paths: If the path contains disallowed characters, aSecurityExceptionis thrown before any file access occurs.Impact
This PR was automatically created by Conviso Platform Auto-Fix.