Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prohibit application tokens to access repositories with GUEST permission #1093

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ikhoon
Copy link
Contributor

@ikhoon ikhoon commented Feb 5, 2025

Motivation:

We are aiming to implement stricter and more explicit access control in Central Dogma.

It has been observed that many tokens are accessing repositories as a GUEST role without being registered with the project. If the token is exposed to the outside, an attacker could gain access to all repositories that allow GUEST access.

To resolve the issue, I propose restricting new tokens from accessing repositories that have GUEST permission. For backward compatibility, the existing tokens are still allowed to access repositories with GUEST permission.

Modifications:

  • Add allowGuestAccess field to Token class to indicate if a token is allowed to access a repository with the GUEST role.
    • If the value is null in tokens.json, it defaults to true for backward compatibility.
  • Fixed MetadataService to prohibit tokens whose allowGuestAccess is false from accessing repositories with the GUEST role.

Result:

New application tokens no longer have access to repositories with the GUEST role.

Motivation:

We are aiming to implement stricter and more explicit access control in
Central Dogma.

It has been observed that many tokens are accessing repositories as a
GUEST role without being registered with the project. If the token is
exposed to the outside, an attacker could gain access to all
repositories that allow GUEST access.

To resolve the issue, I propose restricting new tokens from accessing
repositories that have GUEST permission. For backward compatibility,
the existing tokens are still allowed to access repositories with GUEST
permission.

Modifications:

- Add `allowGuestAccess` field to `Token` class to indicate if a token
  is allowed to access a repository with the GUEST role.
  - If the value is null in `tokens.json`, it defaults to `true` for
    backward compatibility.
- Fixed `MetadataService` to prohibit tokens whose `allowGuestAccess` is
  false from accessing repositories with the GUEST role.

Result:

New application tokens no longer have access to repositories with the
`GUEST` role.
@ikhoon ikhoon added this to the 0.74.0 milestone Feb 5, 2025
@JsonProperty("creation") UserAndTimestamp creation,
@JsonProperty("deactivation") @Nullable UserAndTimestamp deactivation,
@JsonProperty("deletion") @Nullable UserAndTimestamp deletion) {
assert isAdmin != null || isSystemAdmin != null;
this.appId = Util.validateFileName(appId, "appId");
this.secret = Util.validateFileName(secret, "secret");
this.isSystemAdmin = isSystemAdmin != null ? isSystemAdmin : isAdmin;
// Allow guest access by default for backward compatibility.
Copy link
Contributor

Choose a reason for hiding this comment

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

Note: Although allowGuestAccess=true is allowed via API, it isn't allowed via UI. I understood the reason is this field will eventually be deprecated and guest access won't be allowed entirely.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right. Users can't set allowGuestAccess=true either in the UI or the REST API.
allowGuestAccess is true for old tokens or administrative tokens.

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