crates.io
The English user guide is currently in beta preview. Most of the documents have been automatically translated from the Japanese version. Should you find any inaccuracies, please reach out to Flatt Security.
Takumi Guard speaks Cargo's sparse registry protocol, so you can route cargo build, cargo fetch, and cargo add through it with Cargo's built-in source replacement, the same mechanism used for corporate crates.io mirrors. This page covers setup for local development and CI.
Takumi Guard is a sparse registry that requires a token, and Cargo supports token authentication for registries through credential providers from Cargo 1.74. Older Cargo versions cannot use Takumi Guard — upgrade your toolchain with rustup update. With an older Cargo, every command that resolves crates fails with got 401 and this registry requires a token: configure a cargo credential provider for it, even when a token is set. This includes CI jobs that build with an older toolchain to check a crate's minimum supported Rust version (MSRV); run those jobs without the Takumi Guard config.
Setup
Takumi Guard offers three ways to get started for Cargo:
- Anonymous — No account required. Configure the registry with the placeholder token
anonymousto enable package blocking. - Email-Verified — Use an email-verified token (
tg_anon_…) for download tracking and breach notifications. - Org User Token — Use an org user token (
tg_org_…) to track installations across your organization.
Org user tokens require an active base subscription with Guard enabled. See Pricing & Billing for details.
Anonymous Usage
You can use Takumi Guard's package blocking without registering. Add the following to ~/.cargo/config.toml (create the file if it does not exist) so every crate that would come from crates.io resolves through Guard:
[source.crates-io]
replace-with = "takumi-guard"
[registries.takumi-guard]
index = "sparse+https://crates.flatt.tech/"
credential-provider = "cargo:token"
Then provide the placeholder token anonymous in your shell (add it to ~/.zshrc or ~/.bashrc to keep it):
export CARGO_REGISTRIES_TAKUMI_GUARD_TOKEN="anonymous"
The Takumi Guard registry always requires a credential, so Cargo refuses to use it until a token is configured. The value anonymous is treated as anonymous use: blocking applies, but no installs are tracked.
That's the whole setup — package blocking now applies to cargo build, cargo fetch, cargo add, cargo update, and every other command that downloads crates from crates.io, including builds from an existing Cargo.lock. See What You'll See When a Crate Is Blocked for how Cargo reports a block.
Cargo.lock stays portableSource replacement does not change the source recorded in Cargo.lock. Locked crates keep source = "registry+https://github.com/rust-lang/crates.io-index", so the same lock file works on machines with and without Takumi Guard, and enabling Guard does not produce a lock-file diff.
If you prefer not to change your user-level config, put the same [source.crates-io] and [registries.takumi-guard] sections in .cargo/config.toml at the root of a project instead. Cargo merges the project's config with your user-level config.
CARGO_HOME changes where the user-level config livesCargo reads its user-level config from $CARGO_HOME/config.toml, and ~/.cargo is only the default. If CARGO_HOME is set (for example, the official rust Docker images set it to /usr/local/cargo), a config written to ~/.cargo/config.toml is silently ignored and crates are fetched from crates.io directly, without Takumi Guard. Write the config to $CARGO_HOME/config.toml in that case, and use Verify Your Setup to confirm Cargo is going through Takumi Guard.
Email-Verified Access
Registering your email address enables download tracking and breach notifications in addition to package blocking. If a security advisory is published for a crate you previously downloaded, a notification is sent to your registered email address. No Shisho Cloud account is required, and this is free of charge.
If you already have an org user token or email-verified token from using Takumi Guard with npm, PyPI, RubyGems, Go, or Packagist, you don't need to register again — the same token works for Cargo.
Step 1: Register your email
curl -X POST https://crates.flatt.tech/api/v1/tokens \
-H "Content-Type: application/json" \
-d '{"email": "you@example.com", "language": "en"}'
The language field is optional and defaults to "en". Set it to "ja" to receive emails in Japanese. This preference is stored with your token and applies to all future emails, including breach notifications.
You'll receive a welcome email within a few seconds.
Step 2: Get your API key from the email
Your API key is included directly in the welcome email. The key is ready to use immediately — no link to click.
Save this key somewhere secure. If you need a new one, you can regenerate it anytime: curl -X POST -H 'Authorization: Bearer tg_anon_xxxxxx' https://crates.flatt.tech/api/v1/tokens/regenerate
Step 3: Configure Cargo to send the token
Add the registry configuration to ~/.cargo/config.toml (if not already done):
[source.crates-io]
replace-with = "takumi-guard"
[registries.takumi-guard]
index = "sparse+https://crates.flatt.tech/"
credential-provider = "cargo:token"
Then give Cargo the token. Cargo sends the value verbatim as the Authorization header, so the Bearer prefix is required. Either export it in your shell (add it to ~/.zshrc or ~/.bashrc):
export CARGO_REGISTRIES_TAKUMI_GUARD_TOKEN="Bearer tg_anon_xxxxxx"
Or store it in ~/.cargo/credentials.toml:
[registries.takumi-guard]
token = "Bearer tg_anon_xxxxxx"
Cargo now authenticates with your tg_anon_ token on every request to the registry. Your installs are tracked, and breach notifications cover the exact versions you downloaded.
Org User Tokens
Org user tokens (tg_org_…) can be issued from the Takumi / Shisho Cloud console, or by a bot via the Guard API. See Token Management for details on issuing tokens.
A single tg_org_ token works across all Takumi Guard ecosystems (npm, PyPI, RubyGems, Go, Packagist, crates.io). If you have already issued a token for another ecosystem, the same token can be used here.
Once you have a token, add the registry configuration to ~/.cargo/config.toml and provide the token with the Bearer prefix:
[source.crates-io]
replace-with = "takumi-guard"
[registries.takumi-guard]
index = "sparse+https://crates.flatt.tech/"
credential-provider = "cargo:token"
export CARGO_REGISTRIES_TAKUMI_GUARD_TOKEN="Bearer tg_org_xxxxxx"
Your cargo build commands now authenticate with the org user token, enabling organization-wide install tracking and organization-level breach notifications (Slack, webhook, etc.).
Why replace crates.io?
The [source.crates-io] section tells Cargo to fetch everything it would otherwise fetch from crates.io from Takumi Guard instead.
With source replacement, Cargo has no fallback: if Takumi Guard cannot be reached or rejects the token, the command fails instead of downloading directly from crates.io. This guarantees that every public crate is resolved through Takumi Guard's blocklist.
Adding takumi-guard as an extra registry without the [source.crates-io] section does not protect you — dependencies declared in Cargo.toml would still come from crates.io directly.
The credential-provider = "cargo:token" line is required because the registry always asks for a token. Without it, Cargo stops with authenticated registries require a credential-provider to be configured.
CI/CD
- GitHub Actions
- GitLab CI/CD
To integrate Takumi Guard into your GitHub Actions workflow, use the flatt-security/setup-takumi-guard-crates GitHub Action. You can use it anonymously or linked to an organization. The action configures source replacement and the token; your existing cargo build is then protected — blocking applies to your committed Cargo.lock with no migration step.
Anonymous Mode
If you don't have a Shisho Cloud account yet, you can still use Takumi Guard in CI for package blocking. Omit the bot-id input:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: flatt-security/setup-takumi-guard-crates@v1
# No bot-id — anonymous mode, blocking only
# Your existing build is now protected — blocked crates are rejected
# even from a committed Cargo.lock. No migration needed.
- run: cargo build --locked
- run: cargo test --locked
In anonymous mode, the action configures source replacement with the placeholder token anonymous. Blocked crates are rejected during cargo build, but download tracking and breach notifications are not available.
With Shisho Cloud Organization
Linking to a Shisho Cloud organization enables organization-level download tracking and breach notifications (via webhook). No long-lived secrets need to be stored in your CI environment. Authentication is performed securely by exchanging a GitHub OIDC token for a short-lived access token via the Shisho Cloud STS service.
Prerequisites:
- A bot in Shisho Cloud. Copy its Bot ID from the Takumi Guard (Secure Registry) page in the Shisho Cloud console.
- The
id-token: writeandcontents: readpermissions in your workflow job.
jobs:
build:
runs-on: ubuntu-latest
permissions:
id-token: write # Required for OIDC token exchange
contents: read
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: flatt-security/setup-takumi-guard-crates@v1
with:
bot-id: "BT01EXAMPLE..." # Copy from Shisho Cloud console
- run: cargo build --locked
- run: cargo test --locked
The action handles the full OIDC exchange automatically:
- Requests a GitHub OIDC token (with the STS URL as audience, which the bot's trust condition must accept)
- Exchanges it for a short-lived Takumi Guard access token via the STS service
- Configures source replacement for crates.io and exports the token as
CARGO_REGISTRIES_TAKUMI_GUARD_TOKEN
The Bot ID is not a secret. It is a public identifier that specifies the bot to sign in as; authentication relies on verifying the OIDC token against the bot's trust conditions. You can commit it directly in your workflow file. The Shisho Cloud console provides a ready-to-copy workflow snippet with the Bot ID pre-filled.
The access token expires after 30 minutes by default (configurable up to 24 hours via the expires-in input). If authentication fails (invalid bot-id, missing OIDC permission, STS unreachable, etc.), the step exits with a clear error message — there is no silent fallback to anonymous mode.
Action Inputs Reference
| Input | Required | Default | Description |
|---|---|---|---|
bot-id | No | — | Bot ID from Shisho Cloud. Omit for anonymous blocking-only mode. |
registry-url | No | https://crates.flatt.tech | Custom registry URL. Override only if directed by Shisho Cloud support. |
sts-url | No | https://sts.cloud.shisho.dev | STS service URL used for the OIDC → access-token exchange. |
expires-in | No | 1800 (seconds) | Access token lifetime in seconds. Maximum 86400 (24 hours). |
For the full list of inputs and outputs, see the action repository.
In GitLab CI/CD, point Cargo at Takumi Guard in the job's before_script. You can use it anonymously or linked to an organization.
Cargo reads the token and the credential provider from environment variables, but source replacement ([source.crates-io]) has no environment-variable form, so the job writes it to Cargo's config file. In the official rust images, CARGO_HOME is /usr/local/cargo; the commands below fall back to ~/.cargo when it is unset.
Anonymous Mode
If you don't have a Shisho Cloud account yet, you can still use Takumi Guard in CI for package blocking. Add the registry configuration to your job:
build:
image: rust:1-bookworm
variables:
CARGO_REGISTRIES_TAKUMI_GUARD_CREDENTIAL_PROVIDER: "cargo:token"
# "anonymous" is a placeholder token Takumi Guard treats as anonymous use
CARGO_REGISTRIES_TAKUMI_GUARD_TOKEN: "anonymous"
before_script:
# Use Takumi Guard for crates.io
- mkdir -p "${CARGO_HOME:-$HOME/.cargo}"
- printf '[source.crates-io]\nreplace-with = "takumi-guard"\n\n[registries.takumi-guard]\nindex = "sparse+https://crates.flatt.tech/"\n' >> "${CARGO_HOME:-$HOME/.cargo}/config.toml"
script:
- cargo build --locked
- cargo test --locked
In anonymous mode, blocked crates are still rejected, but download tracking and breach notifications are not available.
With Shisho Cloud Organization
To use Takumi Guard in GitLab CI/CD on GitLab.com, authenticate to Shisho Cloud as a bot using OIDC, then configure Cargo with the access token. No long-lived secrets need to be stored in your CI environment, and as with GitHub Actions, package download history is recorded under your organization.
Prerequisites:
- A bot in Shisho Cloud with a GitLab CI/CD trust condition for the target project. See Bot authentication for how to set up the trust condition. Also note the Bot ID of the bot.
- A container image with curl and bash that can run the Linux (glibc) build of shishoctl for x86_64 or aarch64, such as the Debian-based official images (not the
-slimvariants). Alpine-based images are not supported. On arm64 runners, replacex86_64withaarch64in the shishoctl URL.
Add a job like the following to your .gitlab-ci.yml:
build:
image: rust:1-bookworm
id_tokens:
ID_TOKEN:
aud: https://gitlab.com
variables:
SHISHOCLOUD_BOT_ID: "BT01EXAMPLE..." # Copy from Shisho Cloud console
CARGO_REGISTRIES_TAKUMI_GUARD_CREDENTIAL_PROVIDER: "cargo:token"
before_script:
# Install shishoctl
- SHISHOCTL_URL="https://shisho.dev/releases/shishoctl-0.15.0-x86_64-unknown-linux-gnu"
- curl -L $SHISHOCTL_URL -o /usr/local/bin/shishoctl
- chmod +x /usr/local/bin/shishoctl
# Sign in (as bot) and take the access token
- shishoctl auth signin:bot
--bot ${SHISHOCLOUD_BOT_ID}
<<< ${ID_TOKEN}
--expires-in-minutes 30 # Default 30 (max 1440). Adjust to your job
- export ACCESS_TOKEN="$(shishoctl auth print-access-token)"
# Use the access token for Cargo (the "Bearer " prefix is required)
- export CARGO_REGISTRIES_TAKUMI_GUARD_TOKEN="Bearer ${ACCESS_TOKEN}"
- mkdir -p "${CARGO_HOME:-$HOME/.cargo}"
- printf '[source.crates-io]\nreplace-with = "takumi-guard"\n\n[registries.takumi-guard]\nindex = "sparse+https://crates.flatt.tech/"\n' >> "${CARGO_HOME:-$HOME/.cargo}/config.toml"
script:
- cargo build --locked
- cargo test --locked
The access token expires after 30 minutes by default (configurable up to 24 hours via --expires-in-minutes).
Using with Private Crates
Takumi Guard is a read-only security proxy for public crates on crates.io. Source replacement only affects crates.io, so dependencies from other sources keep working and are fetched directly, without going through Guard:
- Crates from an alternate registry (declared under
[registries.<name>]and referenced withregistry = "<name>"inCargo.toml) - Git dependencies (
git = "https://github.com/your-org/private-lib") - Path dependencies (
path = "../private-lib")
[dependencies]
serde = "1" # crates.io → Takumi Guard
internal-lib = { version = "0.3", registry = "my-company" } # your registry, fetched directly
private-lib = { git = "https://github.com/your-org/private-lib" } # Git, fetched directly
Crates fetched directly from an alternate registry, a Git repository, or a local path bypass Takumi Guard's security scanning. This is acceptable for your organization's own crates, but be aware that those crates are not checked against the blocklist.
What Is Not Covered
Takumi Guard protects crates that Cargo resolves from crates.io. The following ways of getting Rust code do not go through the crates.io registry and are not checked against the blocklist:
cargo install --git <url>and Git dependencies inCargo.toml- Path dependencies
cargo-binstall, which downloads prebuilt binaries from GitHub releases and other hosts instead of building from crates.io
cargo install <crate> (without --git) resolves from crates.io and is protected.
What You'll See When a Crate Is Blocked
How Cargo reports a block depends on whether a single version or the whole crate is blocked, and on whether Cargo.lock already pins a version.
A blocked version, with no lock entry: Takumi Guard removes blocked versions from the index, so Cargo resolves to the newest earlier version that is not blocked. The build succeeds without any error.
Cargo.lock pins a blocked version: Cargo cannot find the locked version in the index and fails:
error: failed to select a version for the requirement `<crate> = "^1"` (locked to <version>)
Update the crate to a version that is not blocked, then commit the new lock file:
cargo update -p <crate>
The whole crate is blocked: Takumi Guard refuses the crate's index file, and Cargo fails with the following error, whether or not Cargo.lock pins a version. The test crate hola-takumi is blocked this way:
failed to get successful HTTP response from `https://crates.flatt.tech/ho/la/hola-takumi` (...), got 403
body:
Takumi Guard: hola-takumi is blocked as a malicious package
Remove the dependency from Cargo.toml, or replace it with a safe alternative.
No credential provider is configured: If the credential-provider = "cargo:token" line is missing, Cargo refuses to use the registry:
error: authenticated registries require a credential-provider to be configured
Add the line to the [registries.takumi-guard] section, as shown in Setup.
Crates that Cargo has already downloaded through Takumi Guard are reused from ~/.cargo/registry/cache without contacting Takumi Guard again. If such a crate is blocked later, builds that have it cached keep using it. With an email-verified or organization token, you still receive a breach notification for it. To check a crate again, remove its cached files first:
rm -rf ~/.cargo/registry/cache/*/<crate>-<version>.crate ~/.cargo/registry/src/*/<crate>-<version>
cargo clean # also rebuild from the freshly downloaded source
Verify Your Setup
To confirm that Takumi Guard is working, try adding the harmless test crate hola-takumi to a throwaway project. hola-takumi is a harmless test crate published by GMO Flatt Security for verifying Takumi Guard's behavior, and Takumi Guard blocks it as a whole crate.
cd "$(mktemp -d)" && cargo new verify-takumi-guard && cd verify-takumi-guard
cargo add hola-takumi
If Takumi Guard is configured correctly, Cargo reports Updating `takumi-guard` index and then fails with the following error:
failed to get successful HTTP response from `https://crates.flatt.tech/ho/la/hola-takumi` (...), got 403
body:
Takumi Guard: hola-takumi is blocked as a malicious package
If cargo add succeeds, Cargo is not going through Takumi Guard. If it reports Updating crates.io index, the [source.crates-io] section is not being picked up — re-check ~/.cargo/config.toml (or $CARGO_HOME/config.toml). If it fails with no token found for `takumi-guard` instead of the 403 above, check that CARGO_REGISTRIES_TAKUMI_GUARD_TOKEN is set (anonymous, or Bearer followed by your token).
Publishing
Takumi Guard is a read-only security proxy, and you cannot publish crates to it. Because crates.io is replaced by Takumi Guard, name crates.io explicitly when you publish:
cargo publish --registry crates-io
Without --registry crates-io, cargo publish stops with crates-io is replaced with remote registry takumi-guard. The dependencies cargo publish builds for verification are still fetched through Takumi Guard.
The same applies to the other commands that use the crates.io web API — cargo search, cargo info, cargo owner, and cargo yank: add --registry crates-io. Commands that only download crates (cargo build, cargo fetch, cargo update, cargo install, cargo vendor, …) need no flag and go through Takumi Guard.
Uninstall
To stop using Takumi Guard, remove the source replacement and the token. Cargo.lock does not need to change.
Local Environment
- Remove the
[source.crates-io]and[registries.takumi-guard]sections from~/.cargo/config.toml(and from any project's.cargo/config.tomlwhere you added them). - Remove the token: delete the
export CARGO_REGISTRIES_TAKUMI_GUARD_TOKEN=...line from your shell profile, and the[registries.takumi-guard]section from~/.cargo/credentials.tomlif you stored it there.
unset CARGO_REGISTRIES_TAKUMI_GUARD_TOKEN
CI/CD
- GitHub Actions
- GitLab CI/CD
Remove the Takumi Guard action from your workflow file:
# Remove the following step
- uses: flatt-security/setup-takumi-guard-crates@v1
Remove the CARGO_REGISTRIES_TAKUMI_GUARD_* variables and the lines that write Takumi Guard's configuration to config.toml from your .gitlab-ci.yml. If you linked the job to an organization, also remove the shishoctl lines.
Revoking Org User Tokens
If you are using org user tokens (tg_org_…), revoke them from Guard > Tokens in Shisho Cloud console in addition to updating your local config. Active tokens continue to be billed. See Pricing for details.
Quick Reference
Minimum configuration for each usage tier. Every tier uses the same ~/.cargo/config.toml; only the token differs. Replace tg_anon_xxxxxx / tg_org_xxxxxx with your actual token.
# ~/.cargo/config.toml
[source.crates-io]
replace-with = "takumi-guard"
[registries.takumi-guard]
index = "sparse+https://crates.flatt.tech/"
credential-provider = "cargo:token"
Anonymous
export CARGO_REGISTRIES_TAKUMI_GUARD_TOKEN="anonymous"
Anonymous (email-verified)
export CARGO_REGISTRIES_TAKUMI_GUARD_TOKEN="Bearer tg_anon_xxxxxx"
Organization
export CARGO_REGISTRIES_TAKUMI_GUARD_TOKEN="Bearer tg_org_xxxxxx"