fix: address CodeQL security scan findings#177
Merged
Conversation
Improvements from CodeQL findings.
Pointer-safety (CodeQL tracker does not model Win32 out-parameter APIs):
- crates/openjd-sessions/tests/integration/test_windows_permissions.rs:
Add explicit `!dacl_ptr.is_null()` and `!ace_ptr.is_null()` asserts
before the respective unsafe dereferences in `get_aces_for_object`.
Both pointers are written by Win32 out-parameter APIs
(`GetNamedSecurityInfoW`, `GetAce`), so the original code was correct;
the asserts are defense-in-depth that also break the scanner's taint
path.
- crates/openjd-sessions/src/win32.rs: Add a null guard in
`environment_for_user` after `CreateEnvironmentBlock(...)?` (returning
an empty map), and add an early null-return in
`parse_environment_block`. Documented the null-safety of the latter in
its doc comment.
Cleartext-logging (POSIX UIDs and OpenJD session IDs are not credentials):
- crates/openjd-sessions/tests/integration/test_cross_user.rs: Add a doc
comment on `test_cross_user_runner_uid` explaining that POSIX UIDs are
public on any POSIX system, this test runs only inside an isolated
Docker container under the Cross-User (Linux) CI job, and that
including UIDs in the assertion message is essential for diagnosing
test failures.
- crates/openjd-sessions/src/session.rs: Add a module-level "Session
identifiers" doc section explaining that `session_id` is an opaque
caller-supplied correlation key — not a bearer token, cookie, or
credential — and is deliberately logged so operators can trace log
output across a session. Add brief comments at the two call sites
CodeQL flagged (`log::info!` during session init, and `log::warn!` in
`Drop for Session`) cross-referencing the module-level rationale.
Workflow permissions (hardening):
- .github/workflows/record_pr.yml: Add workflow-root `permissions: {}`.
Caller forwards to a reusable workflow that declares its own
`contents: read`; caller itself needs no token permissions.
- .github/workflows/codeql.yml: Add workflow-root `permissions: {}`.
Also add `contents: read` alongside the existing `security-events:
write` in the forwarded job permissions (explicit rather than relying
on the public-repo default grant for `actions/checkout`).
- .github/workflows/responded.yml: Add workflow-root `permissions: {}`.
Also fix the reusable workflow reference — `reusable_responded.yml`
does not exist in OpenJobDescription/.github; the actual file is
`responded.yml`. This workflow has been silently 404'ing on every
`issue_comment` event since whenever the upstream rename happened.
- .github/workflows/stale_prs_and_issues.yml: Add workflow-root
`permissions: {}`. Job-level permissions (already correct and matching
the reusable workflow's `workflow_call` declaration) preserved.
CI consolidation:
- .github/workflows/openjd-for-js.yml: Removed. Merged into ci.yml as a
new `openjd-for-js` job with its own wasm-specific cache. The original
workflow triggered on `push: mainline`, which never matches anything
in this repo (the active branch is `main`), so it was effectively
running only on PRs. Consolidation fixes the trigger, satisfies the
workflow-permissions hardening rule, and reduces workflow-file count.
- .github/workflows/ci.yml: Add `openjd-for-js` job (build wasm32, run
vitest). Separate cache key keeps it from interleaving with the native
`build-test` cache.
- AGENTS.md: Update the CI Pipeline table to list the new
`openjd-for-js` job and point the `wasm-bindgen-cli` pin reference at
its new location in ci.yml.
Verification:
- cargo clippy --all-features --all-targets --workspace -- -D warnings
- cargo test --workspace --exclude openjd-for-js
- bash scripts/check_copyright_headers.sh
- python3 YAML lint on all modified workflow files
Signed-off-by: Mark <399551+mwiebe@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was the problem/requirement? (What/Why)
CodeQL findings to triage/address.
What was the solution? (How)
Improvements from CodeQL findings.
Pointer-safety (CodeQL tracker does not model Win32 out-parameter APIs):
crates/openjd-sessions/tests/integration/test_windows_permissions.rs: Add explicit
!dacl_ptr.is_null()and!ace_ptr.is_null()asserts before the respective unsafe dereferences inget_aces_for_object. Both pointers are written by Win32 out-parameter APIs (GetNamedSecurityInfoW,GetAce), so the original code was correct; the asserts are defense-in-depth that also break the scanner's taint path.crates/openjd-sessions/src/win32.rs: Add a null guard in
environment_for_userafterCreateEnvironmentBlock(...)?(returning an empty map), and add an early null-return inparse_environment_block. Documented the null-safety of the latter in its doc comment.Cleartext-logging (POSIX UIDs and OpenJD session IDs are not credentials):
crates/openjd-sessions/tests/integration/test_cross_user.rs: Add a doc comment on
test_cross_user_runner_uidexplaining that POSIX UIDs are public on any POSIX system, this test runs only inside an isolated Docker container under the Cross-User (Linux) CI job, and that including UIDs in the assertion message is essential for diagnosing test failures.crates/openjd-sessions/src/session.rs: Add a module-level "Session identifiers" doc section explaining that
session_idis an opaque caller-supplied correlation key — not a bearer token, cookie, or credential — and is deliberately logged so operators can trace log output across a session. Add brief comments at the two call sites CodeQL flagged (log::info!during session init, andlog::warn!inDrop for Session) cross-referencing the module-level rationale.Workflow permissions (hardening):
.github/workflows/record_pr.yml: Add workflow-root
permissions: {}. Caller forwards to a reusable workflow that declares its owncontents: read; caller itself needs no token permissions..github/workflows/codeql.yml: Add workflow-root
permissions: {}. Also addcontents: readalongside the existingsecurity-events: writein the forwarded job permissions (explicit rather than relying on the public-repo default grant foractions/checkout)..github/workflows/responded.yml: Add workflow-root
permissions: {}. Also fix the reusable workflow reference —reusable_responded.ymldoes not exist in OpenJobDescription/.github; the actual file isresponded.yml. This workflow has been silently 404'ing on everyissue_commentevent since whenever the upstream rename happened..github/workflows/stale_prs_and_issues.yml: Add workflow-root
permissions: {}. Job-level permissions (already correct and matching the reusable workflow'sworkflow_calldeclaration) preserved.CI consolidation:
.github/workflows/openjd-for-js.yml: Removed. Merged into ci.yml as a new
openjd-for-jsjob with its own wasm-specific cache. The original workflow triggered onpush: mainline, which never matches anything in this repo (the active branch ismain), so it was effectively running only on PRs. Consolidation fixes the trigger, satisfies the workflow-permissions hardening rule, and reduces workflow-file count..github/workflows/ci.yml: Add
openjd-for-jsjob (build wasm32, run vitest). Separate cache key keeps it from interleaving with the nativebuild-testcache.AGENTS.md: Update the CI Pipeline table to list the new
openjd-for-jsjob and point thewasm-bindgen-clipin reference at its new location in ci.yml.Verification:
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.