Skip to content

fix: [OCISDEV-1140] check the grant read result before the expiration - #811

Merged
2403905 merged 5 commits into
mainfrom
fix/OCISDEV-1140
Nov 12, 2026
Merged

2403905 merged 5 commits into
mainfrom
fix/OCISDEV-1140

Conversation

@2403905

@2403905 2403905 commented Nov 12, 2026 •

Copy link
Copy Markdown

Description

Backport of #804 (stable-9.0) to main.

Original ocis pull request: owncloud/ocis#13436

The storage provider could stop when it read the permissions of a user.
The function ReadUserPermissions in pkg/storage/utils/decomposedfs/node/node.go checked the expiration of a grant before it checked the read error.
A failed read returned a nil grant. The check then used the nil grant.

Changes

  • Check the expiration only when the grant read succeeds.
  • Return false from isGrantExpired for a nil grant.
  • Add the node path to the log message for a failed grant read.
  • Add a unit test for isGrantExpired in pkg/storage/utils/decomposedfs/node/grant_expired_test.go.
  • Add the changelog entry changelog/unreleased/bugfix-decomposedfs-nil-grant-panic.md.

Checks

  • The unit tests in pkg/storage/utils/decomposedfs/node pass.
  • The other callers of isGrantExpired and ReadGrant handle a nil grant correctly.

🤖 Generated with Claude Code

2403905 and others added 4 commits November 12, 2026 10:47
The function ReadUserPermissions in
pkg/storage/utils/decomposedfs/node/node.go checked the expiration of a
grant before it checked the read error. A failed read returned a nil
grant, and the check caused a nil pointer panic.

- Check the expiration only when the grant read succeeds.
- Return false from isGrantExpired for a nil grant.
- Add the node path to the log message for a failed grant read.
- Add a unit test for isGrantExpired.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
(cherry picked from commit bc9a727)
- Add a test for the function ReadUserPermissions in
  pkg/storage/utils/decomposedfs/node/node_test.go. The test stores a
  grant that ReadGrant cannot read. The test checks that the function
  does not panic and gives no permissions.
- Add the license header to
  pkg/storage/utils/decomposedfs/node/grant_expired_test.go.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
(cherry picked from commit b9e8cf5)
The function Unmarshal in pkg/storage/utils/ace/ace.go ignored the error
from unmarshalKV and then read a field of a nil value. The function also
read the first byte of an empty value. Both cases caused a panic.

- Return the error when unmarshalKV fails.
- Return an error for an empty value.
- Add tests in pkg/storage/utils/ace/ace_test.go.
- Update the changelog entry.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
(cherry picked from commit adc8163)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@2403905
2403905 requested a review from a team as a code owner November 12, 2026 09:48
@kw-security

kw-security commented Nov 12, 2026 •

Copy link
Copy Markdown

✅ Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
✅ Open Source Security 0 0 0 0 0 issues
✅ Licenses 0 0 0 0 0 issues
✅ Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

The function Unmarshal in pkg/storage/utils/ace/ace.go read the first
character of the principal without a length check. An empty principal
caused a panic. A principal with one character passed the check, and
the function Grant in pkg/storage/utils/ace/ace.go then caused a panic.
The function unmarshalKV in pkg/storage/utils/ace/ace.go read the value
of a field without an equals sign, and this also caused a panic.

- Return an error for a principal that does not have the form "<type>:<id>".
- Return an error for a field without an equals sign.
- Keep the full value when the value contains an equals sign.
- Ignore empty fields, as the old parser did.
- Add tests in pkg/storage/utils/ace/ace_test.go.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit e3b96ab)
@@ -247,20 +247,28 @@ func (e *ACE) Marshal() (string, []byte) {

// Unmarshal parses a principal string and byte[] into an ACE
func Unmarshal(principal string, v []byte) (e *ACE, err error) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to maintain imperative string parsing?

@@ -0,0 +1,51 @@
// Copyright 2018-2021 CERN

@mklos-kw mklos-kw Nov 12, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the obsolete preables?

@2403905
2403905 merged commit 57f0fa6 into main Nov 12, 2026
14 checks passed
@2403905
2403905 deleted the fix/OCISDEV-1140 branch November 12, 2026 13:47
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.

3 participants