Skip to content

Security: load GPU libraries by full path, keep web pages off the local API, pin CI - #82

Merged
kleju13 merged 1 commit into
mainfrom
t3/security-hardening-pass
Nov 14, 2026
Merged

kleju13 merged 1 commit into
mainfrom
t3/security-hardening-pass

Conversation

@kleju13

@kleju13 kleju13 commented Nov 14, 2026 •

Copy link
Copy Markdown
Owner

What changes

A security pass over the repo. camless's service may run as administrator, from a folder the user's own programs can write to, and it has a local API that any browser tab can send requests at. This closes what the pass found in the code and in the build.

  • GPU libraries by full path. The service loaded nvml.dll for the GPU's sensors by its bare name. On a PC without NVIDIA's driver, Windows then also looked beside camless and in every folder on the PATH, and the service would have loaded a DLL found there as administrator. It now loads it from the directory GetSystemDirectoryW names, or from NVSMI on old drivers. The GPU fan code already used a full path, built from %SystemRoot%; it shares the new function, and so does atiadlxx.dll. A variable is whatever the user's programs set it to.
  • Web pages get 403 from the local API. A request with an Origin other than the API's own address, or with Sec-Fetch-Site other than same-origin or none, is turned away. Until now the Host check and the content types did this job alone. The app, the MCP server, camless report and the installer send neither header. An address typed into a browser still works; a link to the API on a web page gets the 403.
  • /v1/history answers 400 to times out of range. span, from and to must be within 0..=99_999_999_999.
  • CI and the release workflow. Each action is pinned to a commit. The checkout does not keep the token. The tag reaches the packaging scripts through the environment, not written into the script. Tests and builds run with --locked, so a release is built from the versions in Cargo.lock. Dependabot proposes newer actions once a month.
  • rustix 1.1.6, for RUSTSEC-2026-0486. camless does not call the affected functions.
  • docs/how-it-works.md has the new rules, and says that the API has no password.

One thing to know: with --locked, CI fails when a version bump leaves Cargo.lock behind.

Testing

  • cargo test --workspace --release --locked on Linux: 179, 36 and 25 tests pass. cargo test --workspace --locked for x86_64-pc-windows-gnu under Wine: 168, 36 and 27. Two tests are new: one for the Origin rule, one for the System32 path. The history test has the out-of-range cases.

  • The demo service on Linux, with curl: a program's GET 200, the API's own origin 200, Sec-Fetch-Site: none 200, a page elsewhere 403 (with CORS, without, and from another port of the same PC), a foreign Host 421, a negative from 400, a cross-site POST /v1/stop 403, the same from a program 202 and the service stopped.

  • The action commits were read from GitHub and checked against their tags.

  • On a Windows 11 PC with an RTX 4070 SUPER, a build of this branch: camless sensors reads the GPU's temperature, load and power, the same as 0.6.0-beta.5. With a wrong nvml.dll put beside the exe, this build still reads all three. The 0.6.0-beta.5 exe in the same folder loads the wrong one and loses GPU power.

Not tested: atiadlxx.dll on a PC with an AMD card. The release workflow runs only for a tag, so its changes first run with the next release.

AI agent on behalf of kleju13

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Local API requests from other sites are now rejected, while same-origin requests, direct browser access, and programmatic requests remain supported.
    • History queries now accept values only within the documented range.
    • GPU sensor library discovery now checks supported system locations on Windows and Linux.
  • Documentation
    • Clarified Local API request handling and access, and where GPU sensor libraries are found.

…al API, pin CI

The service may run as administrator from a folder the user's programs can
write to. It loaded nvml.dll for the GPU's sensors by its bare name, so on a
PC without NVIDIA's driver Windows also looked beside camless and in every
folder on the PATH. It now loads it by full path from the directory
GetSystemDirectoryW names, as the GPU fan code already did from %SystemRoot%,
and atiadlxx.dll the same way.

The local API answers 403 to a request a browser sends for a page elsewhere:
an Origin other than its own address, or Sec-Fetch-Site other than same-origin
or none. /v1/history answers 400 to times out of range.

CI and the release workflow pin each action to a commit, keep the token out of
the checkout, pass the tag through the environment and build with --locked.
Dependabot proposes newer actions once a month. rustix goes to 1.1.6
(RUSTSEC-2026-0486; camless does not call the affected functions).

Co-Authored-By: Claude <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review.

Walkthrough

The pull request adds cross-site request checks and history-query bounds to the Local API, centralizes NVML library loading, and updates CI and release workflows to pin actions and use locked Cargo commands.

Changes: API validation

Layer / File(s) Summary
Cross-site request checks
src/api.rs, docs/how-it-works.md
The API returns HTTP 403 for requests classified as cross-site. Tests and documentation describe the Origin and Sec-Fetch-Site checks.
History query bounds
src/api.rs
History query seconds must be between 0 and 99,999,999,999 inclusive. Tests cover negative, oversized, and very large values.

Sensor library loading

Layer / File(s) Summary
Platform library resolution
src/sensors/linux.rs, src/sensors/windows.rs, docs/how-it-works.md
Linux loads NVML by library name. Windows looks for NVML in System32 and the NVIDIA NVSMI directory. Windows system directory lookup also supports ADL loading and has a test.
Shared sensor loading
src/sensors.rs, src/drivers/gpu.rs
The sensor module exposes the platform NVML loader. The sensor code and GPU driver use that loader.

CI and release workflows

Layer / File(s) Summary
Workflow and build updates
.github/dependabot.yml, .github/workflows/ci.yml, .github/workflows/release.yml, scripts/package-linux.sh, scripts/package.ps1
Dependabot checks for GitHub Actions updates monthly. CI and release workflows pin action revisions and disable persisted checkout credentials. Release commands use Cargo locked mode, and packaging steps receive the tag through an environment variable.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant APIHandle
  participant RouteHandler
  Client->>APIHandle: Send HTTP request
  APIHandle->>APIHandle: Check Host, Origin, and Sec-Fetch-Site
  alt Request is cross-site
    APIHandle-->>Client: Return HTTP 403
  else Request passes checks
    APIHandle->>RouteHandler: Process request
    RouteHandler-->>Client: Return route response
  end
Loading
Merge Risk: Minimal · up to b9c3c

This change tightens local API access checks, loads GPU libraries by full path, and pins CI actions. No concrete merge-blocking issue was found. Real NVIDIA and AMD driver loading on Windows has not been tested, so a quick hardware check after merge is worthwhile.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names three changes that the changeset implements: GPU libraries (nvml.dll and atiadlxx.dll) are loaded by full path from the system directory, the local API rejects cross-site requests with…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Full details: Title check

Explanation

The title names three changes that the changeset implements: GPU libraries (nvml.dll and atiadlxx.dll) are loaded by full path from the system directory, the local API rejects cross-site requests with 403, and CI and release workflows pin actions and use --locked. The title is long (83 characters) and lists three topics, but each part matches a real change, and the primary security theme is clear. The title does not mention the history bounds check, the rustix upgrade, or Dependabot, but it does not need to cover every detail.

Warning

Some tools did not complete. Review the errors below.

Clippy (1.99.1)

Clippy execution failed

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 196e5e5f-3867-448b-ae19-96abbe87d608
Commits

Reviewing files that changed from the base of the PR and between a91ba17 and b9c3cbe.

Files ignored due to path filters: 1

  • Cargo.lock is excluded by !**/*.lock
Files selected for processing: 11

  • .github/dependabot.yml
  • .github/workflows/ci.yml
  • .github/workflows/release.yml
  • docs/how-it-works.md
  • scripts/package-linux.sh
  • scripts/package.ps1
  • src/api.rs
  • src/drivers/gpu.rs
  • src/sensors.rs
  • src/sensors/linux.rs
  • src/sensors/windows.rs

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@kleju13

kleju13 commented Nov 14, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

AI agent on behalf of kleju13

@coderabbitai

coderabbitai Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@kleju13
kleju13 merged commit b400a23 into main Nov 14, 2026
3 checks passed
@kleju13 kleju13 mentioned this pull request Nov 14, 2026
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