Skip to content

test: parent /changes leaks restricted descendant composition changelog - #353

Open
patricebender wants to merge 4 commits into
mainfrom
test/changelog-hierarchy-descendant-leak
Open

test: parent /changes leaks restricted descendant composition changelog#353
patricebender wants to merge 4 commits into
mainfrom
test/changelog-hierarchy-descendant-leak

Conversation

@patricebender

@patricebender patricebender commented Jul 24, 2026

Copy link
Copy Markdown
Member

A change-tracked composition child that is @restrict'ed within the same service is still exposed through the parent's hierarchical /changes navigation, crossing the authorization boundary.

No fix included, the remediation your call.

@hyperspace-pr-bot hyperspace-pr-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The PR adds a well-structured failing test that documents a real authorization boundary leak. Two issues were flagged: the write-setup calls implicitly depend on the module-level defaults.auth making the test fragile if that default ever changes, and the core assertion is vacuously true if /changes returns nothing at all — a guard assertion that parent rows exist would prevent false positives.

PR Bot Information

Version: 1.29.2

  • Event Trigger: pull_request.opened
  • Correlation ID: 4ed1ca10-8749-11f1-8d33-11770c8ae420
  • LLM: anthropic--claude-4.6-sonnet
  • File Content Strategy: Full file content
  • Experiment Variant: control

Comment thread tests/integration/expressions.test.js
Comment thread tests/integration/expressions.test.js
Comment thread tests/bookshop/db/index.cds Outdated
@patricebender
patricebender force-pushed the test/changelog-hierarchy-descendant-leak branch 2 times, most recently from f516456 to 74d53c6 Compare July 24, 2026 10:30
A child entity is @restrict'ed to admin within a support-scoped service; auto-exposure
carries the entity-level restriction, so a support user is 403 on the child both
directly and via composition navigation. The change-tracking plugin still surfaces the
child's changelog rows through the parent's hierarchical /changes, whose ON condition is
OR-expanded across maxDisplayHierarchyDepth into a SELECT * service ChangeView with no
descendant authorization. Test asserts the parent history carries no restricted-child
rows for such a reader; currently fails on the leaked rows.
@patricebender
patricebender force-pushed the test/changelog-hierarchy-descendant-leak branch from 74d53c6 to 1f7e46a Compare July 24, 2026 10:44
Comment thread tests/bookshop/db/index.cds Outdated
@patricebender
patricebender marked this pull request as ready for review July 27, 2026 13:39
@patricebender
patricebender requested a review from a team as a code owner July 27, 2026 13:39
@hyperspace-pr-bot

Copy link
Copy Markdown
Contributor

Summary

The following content is AI-generated and provides a summary of the pull request:


Test: Parent /changes Leaks Restricted Descendant Composition Changelog

Test

🧪 Adds a failing test to document a known authorization boundary issue where a @restrict-annotated composition child's changelog rows are exposed through the parent entity's hierarchical /changes navigation, even when the user lacks access to the child entity.

Changes

  • tests/bookshop/db/index.cds: Added two new DB-level entities — RestrictedParent (with a @changelog title field) and RestrictedChild (with a @changelog secret field) — connected via a composition relationship.

  • tests/bookshop/srv/feature-testing.cds: Defined a new RestrictedHierService requiring support role, exposing RestrictedParent openly and RestrictedChild restricted to admin via entity-level @restrict. This simulates the single-service scenario where entity-level restrictions should travel with auto-exposure.

  • tests/integration/expressions.test.js: Added a new integration test (does not expose restricted descendant composition changelog rows via parent /changes) that:

    • Creates a parent and child record as an unrestricted user.
    • Verifies a support-only user (bob) receives 403 when accessing the child directly or via composition navigation.
    • Asserts that the parent's /changes feed does not include changelog rows belonging to the restricted child entity (currently a failing assertion documenting the bug).
    • Includes a guard assertion to confirm the parent's own changelog rows are still returned, preventing a vacuous pass.

Note: No fix is included. This PR establishes a test baseline to reproduce the authorization leak for future remediation.


  • 🔄 Regenerate and Update Summary
  • ✏️ Insert as PR Description (deletes this comment)
  • 🗑️ Delete comment
PR Bot Information

Version: 1.29.2

  • Output Template: Default Template
  • LLM: anthropic--claude-4.6-sonnet
  • Summary Prompt: Default Prompt
  • Correlation ID: 9fd4b700-89c0-11f1-98a9-c827e0f6bebc
  • File Content Strategy: Full file content
  • Event Trigger: pull_request.ready_for_review

@hyperspace-pr-bot hyperspace-pr-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The PR introduces a test that documents a security bug where @restrict-ed composition child changelog rows are exposed via the parent's /changes navigation. The test setup has a few correctness issues: the data-creation requests rely implicitly on module-level admin credentials rather than being explicit about why they need them, and the tracked entities are missing the @changelog annotations (entity-level and on the composition field) that are needed for the hierarchical /changes machinery to actually emit child rows — without those, the "no child rows" assertion may pass vacuously because tracking never fires, not because access control blocked anything. Please address the previously raised comments and the new ones before merging.

PR Bot Information

Version: 1.29.2

  • Experiment Variant: control
  • LLM: anthropic--claude-4.6-sonnet
  • Correlation ID: 9fd4b700-89c0-11f1-98a9-c827e0f6bebc
  • File Content Strategy: Full file content
  • Event Trigger: pull_request.ready_for_review

Comment thread tests/integration/expressions.test.js
Comment thread tests/bookshop/db/index.cds
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.

2 participants