Skip to content

Fix shell injection vulnerability in DarkGate CAB unpacker#7

Open
MichaelMVS wants to merge 1 commit intotelekom-security:mainfrom
MichaelMVS:fix-shell-injection
Open

Fix shell injection vulnerability in DarkGate CAB unpacker#7
MichaelMVS wants to merge 1 commit intotelekom-security:mainfrom
MichaelMVS:fix-shell-injection

Conversation

@MichaelMVS
Copy link
Copy Markdown

Replace shell=True with list-based subprocess arguments to prevent command injection.

The DarkGateCABUnpacker was using shell=True when calling 7z to extract .au3 files from CAB archives. The temp file path (f.name) was interpolated directly into a shell command string, which could allow arbitrary command execution if a malicious filename was present.

Changes:

  • Line 144: Changed from shell=True with f-string to list-based [bin_7z, 'e', '-so', f.name, '*.au3']
  • Matches the pattern already used by DarkGateMSIUnpacker

Before:

return subprocess.check_output(
    f'{bin_7z} e -so {f.name} "*.au3"', shell=True
)

After:

return subprocess.check_output(
    [bin_7z, 'e', '-so', f.name, '*.au3']
)

Replace shell=True in subprocess.check_output call with list-based
argument format. The f.name temp file path was being interpolated
into a shell command string, allowing arbitrary command execution
if a malicious filename was present (CVE-class issue for a malware
analysis tool that processes untrusted files).

Also refactored 7z command to use list format consistently with
the MSI unpacker for consistency.
Copilot AI review requested due to automatic review settings April 12, 2026 05:16
Copy link
Copy Markdown

Copilot AI left a 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 hardens the DarkGate CAB unpacking path by removing shell=True from the 7z extraction subprocess call, preventing potential shell command injection during CAB-to-AU3 extraction.

Changes:

  • Replace string-based subprocess.check_output(..., shell=True) invocation with an argument-list invocation for CAB extraction.
  • Align CAB unpacking subprocess usage with the existing MSI unpacking pattern in the same module.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants