Skip to content

fix: Address security audit findings - #369

Draft
nielsenko wants to merge 16 commits into
serverpod:mainfrom
nielsenko:fix-sec-findings
Draft

fix: Address security audit findings#369
nielsenko wants to merge 16 commits into
serverpod:mainfrom
nielsenko:fix-sec-findings

Conversation

@nielsenko

Copy link
Copy Markdown
Collaborator

No description provided.

use() on a catch-all was skipped for the prefix itself, so /api bypassed
the middleware that /api/keys ran.
The unanchored regexes backtracked quadratically, wedging the isolate on a
long value. Text between auth-params is now rejected, not skipped.
Sections were materialised before the response returned, and the count was
unbounded, so a short request could ask for many times the file size.
Random().nextInt(1000000) gave ~20 bits, so boundaries repeated within a
few thousand responses.
Returning the future from inside the try skipped the catch, so a failed
response write left the connection open and the client waiting.
Rejects CR, LF and NUL where every header write funnels, so the defence is
Relic own rather than inherited from dart:io.
No such check exists. The page now says every file in the directory is
served, including dot files.
The host was only segment 0 of a flat string, so a path resolving upwards
could pop it and select another virtual host.
Decoding first turned %2F into a separator no upstream proxy ever saw.
NormalizedPath.fromUri names the safe conversion.
Refuse a mismatched Origin with 403; opt out with allowAnyOrigin. Only the
host is compared, since a TLS-terminating proxy changes scheme and port.
Breaking for apps relying on cross-origin sockets.
Emitted through ParameterValue, so a quote in a filename can no longer end
the value and append a filename*. Parsing is now quote-aware too, or Relic
could not read its own output.
An unescaped realm could close its value and graft a second challenge onto
the response.
io.ContentType takes the parts separately, so they bypassed the CR/LF check
dart:io applies to ordinary header values.
@nielsenko nielsenko self-assigned this Aug 10, 2026
@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 31492070-6740-48d9-b6cc-88762fa9ed76

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Aug 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.76404% with 20 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.35%. Comparing base (ec88f6d) to head (4e72de3).

Files with missing lines Patch % Lines
...ders/typed/headers/content_disposition_header.dart 68.18% 7 Missing ⚠️
packages/relic_io/lib/src/adapter/io_adapter.dart 87.87% 4 Missing ⚠️
...c/headers/typed/headers/authentication_header.dart 86.66% 2 Missing ⚠️
packages/relic_core/lib/src/relic_server.dart 81.81% 2 Missing ⚠️
...ges/relic_core/lib/src/router/normalized_path.dart 80.00% 2 Missing ⚠️
packages/relic_core/lib/src/router/relic_app.dart 0.00% 2 Missing ⚠️
...ib/src/headers/typed/headers/util/auth_params.dart 93.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #369      +/-   ##
==========================================
- Coverage   92.53%   92.35%   -0.19%     
==========================================
  Files         108      109       +1     
  Lines        4544     4655     +111     
  Branches     2310     2355      +45     
==========================================
+ Hits         4205     4299      +94     
- Misses        339      356      +17     
Flag Coverage Δ
relic_core 92.27% <85.84%> (-0.18%) ⬇️
relic_io 93.01% <93.84%> (-0.33%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Hijacking and upgrading detach the connection from the underlying server,
which then reports and closes nothing, so a hijacked socket survived
close(force: true) and connectionsInfo() could not show it.

Track them in the adapter: a forced close destroys them, a graceful close
drains, sends 1001 to WebSocket peers, then closes the rest after a bounded
wait. 40 hijack cycles ignoring the socket leaked 80 sockets before, none
after.
The teardown closed with a 5s timeout and, on timeout, retried close with
none, so a shutdown that could not complete hung the suite instead of
reporting it. Close forcefully once: this test deliberately leaves the
hijacked connection open.

The timeout expectation was also never awaited, so it raced the teardown.
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