Skip to content

fix(workflowengine): prevent unknown upload sizes from matching as zero and add test coverage - #66509

Open
joshtrichards wants to merge 3 commits into
masterfrom
jtr/fix-flow-filesize-unknown
Open

joshtrichards wants to merge 3 commits into
masterfrom
jtr/fix-flow-filesize-unknown

Conversation

@joshtrichards

@joshtrichards joshtrichards commented Nov 10, 2026 •

Copy link
Copy Markdown
Member
  • Resolves: #

Summary

Discovered by working on nextcloud/files_accesscontrol#1259 and nextcloud/documentation#16036.

In the current implementation, a missing or invalid size header is inadvertently treated as zero -- potentially causing unintended rule matches. Consequently, a less or less or equals rule may match requests without a size header, including requests that are not uploads. This happens because assigning false to the numeric $size property gets silently coerces to 0 (no error because strict_types isn't yet active in this part of the code base).

Changes:

  • Fix unknown upload sizes being treated as zero in workflow rules by allow false in the property type so the existing guard returns “no match” for unknown sizes (as intended; that code/check is pre-existing).
  • Add regression coverage for missing and invalid headers, cached results, valid zero-byte sizes, threshold equality, header precedence, and POST/PUT fallback.

TODO

  • ...

Checklist

AI (if applicable)

  • The content of this PR was partly or fully generated using AI

@joshtrichards joshtrichards added this to the Nextcloud 36 milestone Nov 10, 2026
@joshtrichards
joshtrichards requested a review from a team as a code owner November 10, 2026 17:06
@joshtrichards
joshtrichards removed the request for review from a team November 10, 2026 17:06
@joshtrichards joshtrichards added the 3. to review Waiting for reviews label Nov 10, 2026
Allow the cached file size to be `false` when no valid size header is
available. Previously, assigning `false` to the numeric property coerced it to zero, causing some size checks to match unexpectedly.

Preserving `false` lets the existing guard reject the check instead of
comparing an unknown size as zero.

Signed-off-by: Josh <josh.t.richards@gmail.com>
Add regression coverage ensuring missing or invalid size headers do not match any size operator, including when the unknown result is cached.

Cover valid zero-byte sizes, threshold equality, header precedence,
POST/PUT Content-Length fallback, and cached-result reuse.

Assisted-by: Copilot:gpt-6.1-sol

Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
@joshtrichards

Copy link
Copy Markdown
Member Author

/backport to stable35

@joshtrichards

Copy link
Copy Markdown
Member Author

/backport to stable34

@joshtrichards

Copy link
Copy Markdown
Member Author

/backport to stable33

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants