Skip to content

Security: Potential ANSI Escape Sequence Injection in Terminal Output#634

Open
barttran2k wants to merge 1 commit intooffa:masterfrom
barttran2k:contribai/fix/security/potential-ansi-escape-sequence-injection
Open

Security: Potential ANSI Escape Sequence Injection in Terminal Output#634
barttran2k wants to merge 1 commit intooffa:masterfrom
barttran2k:contribai/fix/security/potential-ansi-escape-sequence-injection

Conversation

@barttran2k
Copy link
Copy Markdown
Contributor

Problem

In ensure_sorted.py, app names are extracted from the README.md file using regex and printed directly to the terminal with ANSI escape codes. If an app name in the README contains crafted ANSI escape sequences, it could manipulate terminal output, potentially hiding malicious content or confusing the CI output (terminal injection).

Severity: low
File: ensure_sorted.py

Solution

Sanitize app names before printing by stripping or escaping ANSI control characters: app_name = re.sub(r'\x1b\[[0-9;]*m', '', app_name) before appending to self.apps.

Changes

  • ensure_sorted.py (modified)

Testing

  • Existing tests pass
  • Manual review completed
  • No new warnings/errors introduced

In `ensure_sorted.py`, app names are extracted from the README.md file using regex and printed directly to the terminal with ANSI escape codes. If an app name in the README contains crafted ANSI escape sequences, it could manipulate terminal output, potentially hiding malicious content or confusing the CI output (terminal injection).

Affected files: ensure_sorted.py

Signed-off-by: Trần Bách <45133811+barttran2k@users.noreply.github.com>
@offa offa added the ci label Apr 7, 2026
@offa
Copy link
Copy Markdown
Owner

offa commented Apr 7, 2026

App names must not contain ANSI escape sequences. I would prefer to throw an error in such cases.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants