Repository navigation
fix(authz): restriction check fails closed when the PDP bulk call errors (wiki-v2#492) - #51
Merged
Merged
Conversation
…ors (docmost#492) `HttpAuthzClient.checkBulk` collapses any failure (transport, timeout, non-2xx, malformed body) into all-`false`. `PdpPagePermissionRepo.canUserEditPage` read `locked` from that same batch, and `locked=false` RELAXES access: upstream `PageAccessService` then falls back to the space role, which comes from a separate call that may well have succeeded. So during a PDP error a restricted page read as unrestricted and opened to every space member. - HttpAuthzClient.tryCheckBulk: like checkBulk, but reports failure as `null` (including any non-boolean element, so a Byzantine `locked: "yes"` can't read as unrestricted). checkBulk keeps its exact contract. Added to the RemoteAuthzClient port. - canUserEditPage: an unknown result means {hasAnyRestriction: true, canAccess: false, canEdit: false}, so upstream trusts the PDP decision and denies. - Specs: client failure polarity (null on every failure mode); repo outage now covers canUserEditPage; an end-to-end PageAccessService test pins the exact precondition (page call fails, space role allows), plus a control proving the pre-fix reading fell through to the space role. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TL;DR
The fork's page-restriction check (
locked) failed open when the PDP bulk call errored. The failure read as "unrestricted", so upstream fell back to the space role and a restricted page opened to every space member. With this change an unknown restriction state is treated as restricted with no access. The change is CCC authz code only (apps/server/src/authz/); no upstream-owned file is touched.Context
HttpAuthzClient.checkBulkcollapses every failure (transport, timeout, non-2xx, malformed body) into all-false. That is safe forview/edit, where false means deny.PdpPagePermissionRepo.canUserEditPagereadslockedfrom the same batch, but forlockeda false means unrestricted.PageAccessServicethen trusts the space role (CASL), which is fetched by a separate call that may have succeeded. So a PDP error could expose a restricted page. This is the AGENTS.md "a missing restriction fails open" class, P0-adjacent.Found while planning the page-lifecycle work in wiki-v2 issue 485. Those
/v1routes usevalidateCanEdit/validateCanViewas defense in depth, so this should land first. Plan, progress and tradeoffs are on the tracking issue: https://github.com/cccvu/wiki-v2/issues/492#issuecomment-5781600903Related issues
Closes #492) merges.What changed
authz/http-authz.client.ts: newtryCheckBulk(), which returnsnullon any failure, including any non-boolean result element, so a Byzantinelocked: "yes"can't read as unrestricted.checkBulk()keeps its exact contract (all-false on failure, per-element coercion); both share one privatebulkResults(), which now also logs a malformed envelope.authz/port/remote-authz-client.port.ts:tryCheckBulkadded to theRemoteAuthzClientport.authz/pdp-page-permission.repo.ts:canUserEditPageusestryCheckBulk. An unknown result becomes{hasAnyRestriction: true, canAccess: false, canEdit: false}, so upstream denies.docs/architecture/external-services.md: states that a failedlockedmeans restricted, for third-party PDP implementers.authorization-service.openapi.jsonis unchanged.How this was tested
pnpm exec jest src/authz src/service-bridge src/editor-compat(the CIdocmost-authzlane): 80 suites, 750 passed, 57 skipped (real-Postgres specs, which self-skip without a DB).http-authz.client.spec.ts:tryCheckBulkreturns strict results on a 200,[]without a call for an empty batch, andnullon a network error, non-200, non-array, wrong length, and a non-boolean element.leakage/primitives.spec.ts:canUserEditPagereturns restricted with no access.PageAccessServicewith the exact precondition: the page call fails while the space role allows.validateCanEditandvalidateCanViewWithPermissionsthrowForbiddenException.npx tsc --noEmit -p tsconfig.build.json: clean.bash scripts/check-upstream-boundary.sh(super repo, against the committed fork HEAD): passes, upstream boundary intact.AWS / infra apply
N/A. Fork code only, and it ships with the next release after the super-repo gitlink bump.
Checklist
Scope
Tests
Docs & contracts
README/docs// an ADR), or N/A.Safety (this is a security-first, deny-by-default platform)
UPSTREAM_MODIFICATIONS.md); proprietary/authz logic stays out-of-process.Housekeeping
Known limitations / follow-ups
lockedneeded this. It is the one bulk-checked permission wherefalserelaxes access.filterResourcesreturning empty on failure, which orphans children duringmovePageToSpace, is a separate case. It's tracked with the wiki-v2 issue 485 follow-ups.🤖 Generated with Claude Code