[PR #5613] [MERGED] modif: Escape control characters of the command line #5571

Closed
opened 2026-05-05 10:40:52 -06:00 by gitea-mirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netblue30/firejail/pull/5613
Author: @layderv
Created: 1/22/2023
Status: Merged
Merged: 2/14/2023
Merged by: @netblue30

Base: masterHead: escape-cntrl-sequences


📝 Commits (2)

📊 Changes

3 files changed (+74 additions, -1 deletions)

View changed files

📝 src/include/common.h (+1 -0)
📝 src/lib/common.c (+58 -0)
📝 src/lib/pid.c (+15 -1)

📄 Description

Names and commands can contain control characters:

firejail --name="$(echo -e '\e[31mRed\n\b\b\bText\e[0m')" sleep 10s

results in "Text" printed in red.

Prevent commands like --tree to control the terminal.

I've tested some control characters and I can't do worse than making jails disappear from --tree (by controlling the cursor) and possibly output anything to console (hijacking a console output). Reading various documentations and forums, I didn't find interesting control characters like "writing to file" or "execute command", that resulted in CVEs in the past.

  • Which other functions should be fixed? print_elem is the one used in --tree.
  • Which other control characters should be escaped?
  • In if (iscntrl(*c)) {, if the *ccharacter is not one in the switch, the character is discarded. Is this the behavior you want, or do you prefer to allow that character?

Before submitting this PR, I contacted @netblue30.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netblue30/firejail/pull/5613 **Author:** [@layderv](https://github.com/layderv) **Created:** 1/22/2023 **Status:** ✅ Merged **Merged:** 2/14/2023 **Merged by:** [@netblue30](https://github.com/netblue30) **Base:** `master` ← **Head:** `escape-cntrl-sequences` --- ### 📝 Commits (2) - [`ab4bd9c`](https://github.com/netblue30/firejail/commit/ab4bd9c707cd3e872039abd00b3274a01d7dd1c2) Escape control characters - [`74e9445`](https://github.com/netblue30/firejail/commit/74e94458e77270b99f49fc0d95cea05b881411c0) Style changes ### 📊 Changes **3 files changed** (+74 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `src/include/common.h` (+1 -0) 📝 `src/lib/common.c` (+58 -0) 📝 `src/lib/pid.c` (+15 -1) </details> ### 📄 Description Names and commands can contain control characters: ``` firejail --name="$(echo -e '\e[31mRed\n\b\b\bText\e[0m')" sleep 10s ``` results in "Text" printed in red. Prevent commands like `--tree` to control the terminal. I've tested some control characters and I can't do worse than making jails disappear from `--tree` (by controlling the cursor) and possibly output anything to console (hijacking a console output). Reading various documentations and forums, I didn't find interesting control characters like "writing to file" or "execute command", that resulted in CVEs in the past. * Which other functions should be fixed? `print_elem` is the one used in `--tree`. * Which other control characters should be escaped? * In `if (iscntrl(*c)) {`, if the `*c`character is not one in the `switch`, the character is discarded. Is this the behavior you want, or do you prefer to allow that character? Before submitting this PR, I contacted @netblue30. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
gitea-mirror 2026-05-05 10:40:52 -06:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/firejail#5571
No description provided.