Skip to content

fix: address the first CodeQL findings - #5

Merged
UnmetDecade merged 1 commit into
mainfrom
fix/codeql-alerts
Nov 15, 2026
Merged

UnmetDecade merged 1 commit into
mainfrom
fix/codeql-alerts

Conversation

@UnmetDecade

Copy link
Copy Markdown
Owner

Summary

Closes the three CodeQL alerts that the first analysis run opened on main.

Alert Rule Fix
#2 platform/posix/net_posix.cpp cpp/command-line-injection (critical) popen() is gone; ip/nmcli run through posix_spawnp() with an argv
#3 core/projection/carplay/airplay/server.cpp cpp/comparison-with-wider-type port fallback iterates in uint32_t and stops at 65535
#1 core/projection/carplay/usb/pair_record.cpp cpp/redundant-null-check-simple guard the dereference, keep found optional

Details

Command injection. The wired CarPlay bring-up built shell strings from the interface name and from the caller-supplied link-local address (--wired-ll). Single quotes were the only defence. It now passes an explicit argument vector, so no shell parses the values; both are also validated up front (charset and length), because ip itself would read a leading - as an option. Behaviour is unchanged otherwise: same commands, same output capture, same exit-code checks.

Port fallback. for (uint16_t p = cfg_.port; p < cfg_.port + 20; ++p) compared a narrow type with a promoted int; near 65535 the counter wraps and the loop never terminates. The loop is now uint32_t and clamps at the end of the port space.

Redundant null check. loadWiredPairCerts() was followed by if (!*found) and then if (found != nullptr) *found = false — the second check was dead. The first is now guarded.

Verification

  • Full build in the Ubuntu 24.04 CI image: no errors or new warnings.
  • iap2_test (with a generated test identity), m3_test, aa_wire_test: all pass.
  • No credentials or identity material touched.

🤖 Generated with Claude Code

- net_posix.cpp (cpp/command-line-injection, critical): the wired-NCM
  bring-up concatenated the interface name and the caller-supplied
  link-local address into a shell command and ran it with popen(). Run
  ip/nmcli through posix_spawnp() with an explicit argv instead, and
  reject interface names and addresses whose characters have no business
  in either. The shell is gone, so quoting bugs cannot become command
  execution.

- server.cpp (cpp/comparison-with-wider-type): the RTSP port fallback
  compared a uint16_t loop variable against an int expression, which
  would wrap at 65535. Iterate in uint32_t and stop at the end of the
  port space.

- pair_record.cpp (cpp/redundant-null-check-simple): `found` was
  dereferenced before the null check that followed it. Guard the
  dereference and keep the out-parameter optional.

Verified in the Ubuntu 24.04 CI image: full build, and iap2_test /
m3_test / aa_wire_test all pass.

Co-Authored-By: Claude Code <noreply@anthropic.com>
@UnmetDecade
UnmetDecade merged commit c8e95e4 into main Nov 15, 2026
6 checks passed
@UnmetDecade
UnmetDecade deleted the fix/codeql-alerts branch November 15, 2026 01:46
UnmetDecade added a commit that referenced this pull request Nov 15, 2026
The landing pages linked architecture.md, PROTOCOL-NOTES.md and
projection-backend.md directly. With .nojekyll set, Pages serves those as
text/markdown, so clicking a card showed the raw source instead of the
rendered document. Point them at the GitHub blob URLs, matching the
README/CONTRIBUTING/SECURITY links right below them, in both languages.

Also record the CodeQL fixes merged in #5 under Unreleased.

Co-authored-by: UnmetDecade <UnmetDecade@users.noreply.github.com>
Co-authored-by: Claude Code <noreply@anthropic.com>
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.

1 participant