Skip to content

🛡️ Sentinel: [HIGH] Fix missing null-termination in tinysrp strncpy#47

Merged
ManupaKDU merged 6 commits intomainfrom
sentinel-tinysrp-strncpy-fix-7084194960663180766
Apr 5, 2026
Merged

🛡️ Sentinel: [HIGH] Fix missing null-termination in tinysrp strncpy#47
ManupaKDU merged 6 commits intomainfrom
sentinel-tinysrp-strncpy-fix-7084194960663180766

Conversation

@ManupaKDU
Copy link
Copy Markdown

🚨 Severity: HIGH
💡 Vulnerability: The strncpy function in package/network/services/ead/src/tinysrp/tphrase.c and t_client.c was used to copy usernames into fixed-size buffers (MAXUSERLEN) without explicitly bounding the copy to MAXUSERLEN - 1 and adding a null terminator. strncpy does not guarantee null-termination if the source string length is equal to or greater than the specified bound.
🎯 Impact: If a username larger than the buffer is provided (or parsed from a file), the resulting buffer will lack a null terminator. This can lead to out-of-bounds reads or writes during subsequent string operations (like strlen, strcpy, or when used as format strings), potentially leading to crashes, information disclosure, or memory corruption.
🔧 Fix: Bounded the strncpy copies to MAXUSERLEN - 1 and explicitly set the null terminator at buffer[MAXUSERLEN - 1] = '\0' immediately following the copy.
Verification: Verified that the fix compiles correctly by manually building the ead service via make -C package/network/services/ead/src. The codebase was cleaned of build artifacts.

Also added a journal entry to .jules/sentinel.md documenting this learning.


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

The `strncpy` function was used to copy usernames into fixed-size buffers
(`MAXUSERLEN`) in `tphrase.c` and `t_client.c` without explicitly bounding
to `MAXUSERLEN - 1` and adding a null terminator. If a username larger
than the buffer is provided, the buffer will lack a null terminator,
leading to potential out-of-bounds reads or writes during subsequent string
operations.

This commit updates `tphrase.c` and `t_client.c` to safely bound the
copy to `MAXUSERLEN - 1` and explicitly append a null byte.

Signed-off-by: Jules Sentinel <jules@example.com>

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 5 commits April 5, 2026 01:59
The `strncpy` function was used to copy usernames into fixed-size buffers
(`MAXUSERLEN`) in `tphrase.c` and `t_client.c` without explicitly bounding
to `MAXUSERLEN - 1` and adding a null terminator. If a username larger
than the buffer is provided, the buffer will lack a null terminator,
leading to potential out-of-bounds reads or writes during subsequent string
operations.

This commit updates `tphrase.c` and `t_client.c` to safely bound the
copy to `MAXUSERLEN - 1` and explicitly append a null byte.

Additionally, this commit updates `.github/workflows/build.yml` to
update the apt sources for the outdated Debian Buster container used in CI,
pointing it to `archive.debian.org` to prevent 404 Not Found errors during
the `apt-get update` step.

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>
The `strncpy` function was used to copy usernames into fixed-size buffers
(`MAXUSERLEN`) in `tphrase.c` and `t_client.c` without explicitly bounding
to `MAXUSERLEN - 1` and adding a null terminator. If a username larger
than the buffer is provided, the buffer will lack a null terminator,
leading to potential out-of-bounds reads or writes during subsequent string
operations.

This commit updates `tphrase.c` and `t_client.c` to safely bound the
copy to `MAXUSERLEN - 1` and explicitly append a null byte.

Additionally, this commit updates `.github/workflows/build.yml` to
update the apt sources for the outdated Debian Buster container used in CI,
pointing it to `archive.debian.org` to prevent 404 Not Found errors during
the `apt-get update` step.

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>
The `strncpy` function was used to copy usernames into fixed-size buffers
(`MAXUSERLEN`) in `tphrase.c` and `t_client.c` without explicitly bounding
to `MAXUSERLEN - 1` and adding a null terminator. If a username larger
than the buffer is provided, the buffer will lack a null terminator,
leading to potential out-of-bounds reads or writes during subsequent string
operations.

This commit updates `tphrase.c` and `t_client.c` to safely bound the
copy to `MAXUSERLEN - 1` and explicitly append a null byte.

Additionally, this commit updates `.github/workflows/build.yml` to
update the apt sources for the outdated Debian Buster container used in CI,
pointing it to `archive.debian.org` to prevent 404 Not Found errors during
the `apt-get update` step.

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>
The `strncpy` function was used to copy usernames into fixed-size buffers
(`MAXUSERLEN`) in `tphrase.c` and `t_client.c` without explicitly bounding
to `MAXUSERLEN - 1` and adding a null terminator. If a username larger
than the buffer is provided, the buffer will lack a null terminator,
leading to potential out-of-bounds reads or writes during subsequent string
operations.

This commit updates `tphrase.c` and `t_client.c` to safely bound the
copy to `MAXUSERLEN - 1` and explicitly append a null byte.

Additionally, this commit updates `.github/workflows/build.yml` and
`.github/workflows/check-kernel-patches.yml` to update the apt sources
for the outdated Debian Buster container used in CI, pointing it to
`archive.debian.org` to prevent 404 Not Found errors during the
`apt-get update` step, and includes `python3-pyelftools` to satisfy new
build dependencies.

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>
…ctions CI 404

The `strncpy` function was used to copy usernames into fixed-size buffers
(`MAXUSERLEN`) in `tphrase.c` and `t_client.c` without explicitly bounding
to `MAXUSERLEN - 1` and adding a null terminator. If a username larger
than the buffer is provided, the buffer will lack a null terminator,
leading to potential out-of-bounds reads or writes during subsequent string
operations.

This commit updates `tphrase.c` and `t_client.c` to safely bound the
copy to `MAXUSERLEN - 1` and explicitly append a null byte.

Additionally, this commit updates `.github/workflows/build.yml` and
`.github/workflows/check-kernel-patches.yml` to update the apt sources
for the outdated Debian Buster container used in CI, pointing it to
`archive.debian.org` to prevent 404 Not Found errors during the
`apt-get update` step, and includes `python3-pyelftools` to satisfy new
build dependencies.

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>
@ManupaKDU ManupaKDU merged commit 89389c1 into main Apr 5, 2026
179 of 180 checks passed
@ManupaKDU ManupaKDU deleted the sentinel-tinysrp-strncpy-fix-7084194960663180766 branch April 5, 2026 12:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment