Skip to content

🔒 Sentinel: [HIGH] Fix buffer overflow in patch-cmdline#88

Merged
ManupaKDU merged 4 commits into
mainfrom
security/patch-cmdline-buffer-overflow-10592918498490356243
May 22, 2026
Merged

🔒 Sentinel: [HIGH] Fix buffer overflow in patch-cmdline#88
ManupaKDU merged 4 commits into
mainfrom
security/patch-cmdline-buffer-overflow-10592918498490356243

Conversation

@ManupaKDU
Copy link
Copy Markdown

🎯 What: Buffer overflow vulnerability in patch-cmdline.c and a memory unmapping bug.
⚠️ Risk: An attacker or misconfigured script could provide a command line that causes a buffer overflow, potentially corrupting memory or leading to arbitrary code execution within the context of the tool. Additionally, the munmap call in the error path was using the string length (len) instead of the mapped size (search_space + CMDLINE_MAX), leading to memory leaks or undefined behavior.
🛡️ Solution: Replaced strcpy with strncpy, using CMDLINE_MAX - 9 as the limit to prevent the buffer from being overrun, ensuring the buffer remains safely within bounds and correctly null-terminated (thanks to a preceding memset). Corrected the munmap size to match the original mmap size.


PR created automatically by Jules for task 10592918498490356243 started by @manupawickramasinghe

Replace `strcpy` with `strncpy` to prevent buffer overflows when copying the command line into the mapped buffer. Also fixed the `munmap` cleanup logic which was using an incorrect size.

Co-authored-by: manupawickramasinghe <73810867+manupawickramasinghe@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

google-labs-jules Bot and others added 3 commits May 22, 2026 15:30
Replace `strcpy` with `strncpy` to prevent buffer overflows when copying the command line into the mapped buffer. Also fixed the `munmap` cleanup logic which was using an incorrect size.

Signed-off-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>

Co-authored-by: manupawickramasinghe <73810867+manupawickramasinghe@users.noreply.github.com>
Replace `strcpy` with `strncpy` to prevent buffer overflows when copying the command line into the mapped buffer. Also fixed the `munmap` cleanup logic which was using an incorrect size.

Signed-off-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>

Co-authored-by: manupawickramasinghe <73810867+manupawickramasinghe@users.noreply.github.com>
…918498490356243

Signed-off-by: M.N Wickramasinghe <95234271+ManupaKDU@users.noreply.github.com>
@ManupaKDU ManupaKDU merged commit 7585b7f into main May 22, 2026
7 of 8 checks passed
@ManupaKDU ManupaKDU deleted the security/patch-cmdline-buffer-overflow-10592918498490356243 branch May 22, 2026 16:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant