Skip to content

Conversation

Turbo87
Copy link
Member

@Turbo87 Turbo87 commented Sep 12, 2025

Setting this environment variable will cause crates.io to reject new API token creation requests with the error message set inside the environment variable. This can be useful to e.g. temporarily pause API token creation during ongoing phishing campaigns.

Resolves #11892

Setting this environment variable will cause crates.io to reject new API token creation requests with the error message set inside the environment variable. This can be useful to e.g. temporarily pause API token creation during ongoing phishing campaigns.
@Turbo87 Turbo87 added the C-internal 🔧 Category: Nonessential work that would make the codebase more consistent or clear label Sep 12, 2025
Copy link
Member

@carols10cents carols10cents left a comment

Choose a reason for hiding this comment

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

Nice tests! It'd probably be friendlier to users to hide the new token form as well, but this will do for a first impl.

@walterhpearce
Copy link

Can we add logging during the disablement period, to explicitly capture all attempts to create a token during the disabled period?

@carols10cents
Copy link
Member

Can we add logging during the disablement period, to explicitly capture all attempts to create a token during the disabled period?

It's there: https://github.com/rust-lang/crates.io/pull/11894/files#diff-13b69ea8d077bfdc7f18964826bd9ca405a8225da8fe8b3373dc0a3c7f964aa5R132-R135

Comment on lines 132 to 135
warn!(
"Blocked token creation for user `{}` (id: {}) due to disabled flag (token name: `{}`)",
user.gh_login, user.id, new.api_token.name
);
Copy link
Member Author

Choose a reason for hiding this comment

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

@walterhpearce isn't that what we're doing here? 😅

Choose a reason for hiding this comment

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

I missed it because I am not smart. Can we log the full request during this period? Headers + addresses.

Copy link
Member Author

Choose a reason for hiding this comment

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

I've added the IP address and the headers, minus cookie and authorization header to not unnecessarily expose these in our logs.

Choose a reason for hiding this comment

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

Lgtm

Copy link
Contributor

@LawnGnome LawnGnome left a comment

Choose a reason for hiding this comment

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

LGTM.

@Turbo87 Turbo87 enabled auto-merge September 12, 2025 15:38
@Turbo87 Turbo87 merged commit 55ecaad into rust-lang:main Sep 12, 2025
10 checks passed
@Turbo87 Turbo87 deleted the disable-token-creation branch September 12, 2025 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-backend ⚙️ C-internal 🔧 Category: Nonessential work that would make the codebase more consistent or clear
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Have a way to disable creation of new API tokens
6 participants