Repository navigation
Fix commit repository authorization (BUG-317102) - #1977
Merged
Merged
Conversation
Require repository-scoped READ grants on both commit endpoints and prevent outbound SCM path or JSON injection. Preserve legitimate references and configured SCM identities. Provide read-only repository tokens with enforced expiry and revocation, widen grant storage without changing collation semantics, and document the database and caller rollout.
Use the existing MANAGE_SCRIPT_TOKEN permission on SYSTEM for both commit routes, retaining GitHub repository validation and safe URL construction. Remove repository-specific authorization infrastructure, schema migration, token provisioning and token-cache changes. The resulting patch requires only a service deployment; existing system administrators retain access, while ordinary readers receive 403.
Keep READ access on both commit endpoints and require a retained build for the selected SCM and complete repository identity before SCM access. Preserve new-commit and branch views while blocking repositories without builds, including for admins. Use safe GitHub URLs and serialized Phabricator parameters. No database schema or GitHub token changes. Test plan: clean Maven reactor suite passed (872 tests); scoped Spotless and whitespace checks passed.
osoriano
reviewed
Nov 14, 2026
| // Binary comparison preserves accents, trailing spaces, and complete identities even | ||
| // when the table's collation treats those values as equivalent. No prefix or LIKE match. | ||
| String query = | ||
| HAS_BUILD_FOR_REPOSITORY[caseInsensitiveScm ? 1 : 0][ |
Contributor
There was a problem hiding this comment.
If this query becomes expensive, we can use caching to help, similar to Entitlements
osoriano
approved these changes
Nov 14, 2026
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.
Summary
Problem (Why)
Both commit endpoints let baseline readers use Teletraan's broad SCM credential to read arbitrary repositories. GitHub repository input could also alter the outbound API path. Addresses BUG-317102.
Solution (What + How)
READpermission and require at least one retained build for the complete repository and selected configured SCM before either endpoint requests SCM data. Repositories without a matching build return HTTP 403, including for administrators.owner/repositoryinput, encode outbound path segments, and serialize Phabricator parameters as JSON so request fields cannot override the checked repository. Reject missing, malformed or duplicate repository identities before SCM access.Published build metadata defines a shared repository allowlist: every READ caller can access any repository with a matching build, and publishers can expand it through build metadata. This workaround does not provide per-user repository ownership authorization.
Deployment requires only the service update. No database schema change, migration, new repository grants, GitHub credential change, token issuance change or token cache change is required. Each commit request adds a database existence query; existing indexes do not cover this lookup, so it can scan retained builds.
Test Plan
git diff --checkpassed.