# Takumi Guard crates.io Support Released

Takumi Guard now supports **crates.io** alongside npm, PyPI, RubyGems, Go, and Packagist.

Rust projects using **Cargo** can now route `cargo build`, `cargo fetch`, and `cargo add` through Takumi Guard to block known-malicious crates before they reach your CI or development environment.

![Takumi Guard now supports crates.io](/docs/_md-assets/2c3ee60fb5-eyecatch.png)

## Overview {#overview}

Takumi Guard is a security proxy that sits between your package manager and the upstream registry. It checks every install request against GMO Flatt Security's threat database and blocks known-malicious packages.

With this release, the same protection that npm, Python, Ruby, Go, and PHP users have is now available for the Rust ecosystem:

- **[Package Blocking](/docs/t/guard/features/package-blocking)**: Malicious crates are blocked before any code is fetched
- **[Download Tracking](/docs/t/guard/features/installation-logs)**: Records install history for authenticated users
- **[Breach Notifications](/docs/t/guard/features/breach-notifications)**: Get notified if a crate you installed is later flagged as malicious

The proxy speaks Cargo's standard [sparse registry protocol](https://doc.rust-lang.org/cargo/reference/registry-index.html#sparse-protocol) and plugs in through Cargo's built-in [source replacement](https://doc.rust-lang.org/cargo/reference/source-replacement.html), the same mechanism used for corporate crates.io mirrors — so no tooling changes are needed, just a one-time Cargo configuration.

:::info Requires Cargo 1.74 or newer
Takumi Guard requires **Cargo 1.74 or later** (Rust 1.74 or later). Its registry requires a token, and Cargo can send registry tokens only through credential providers, which were added in Cargo 1.74. 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. Upgrade with `rustup update`. See the [crates.io quickstart](/docs/t/guard/quickstart/crates) for details, including CI jobs that check an older minimum supported Rust version (MSRV).
:::

## Getting Started {#getting-started}

The following works anonymously — no account or registration required. Add Takumi Guard to `~/.cargo/config.toml` so every crate that would come from crates.io resolves through the proxy:

```toml
[source.crates-io]
replace-with = "takumi-guard"

[registries.takumi-guard]
index = "sparse+https://crates.flatt.tech/"
credential-provider = "cargo:token"
```

The registry always requires a token, so provide the placeholder `anonymous`, which Takumi Guard treats as anonymous use:

```bash
export CARGO_REGISTRIES_TAKUMI_GUARD_TOKEN="anonymous"
```

That's the whole setup. Blocking applies to every Cargo command that downloads crates, **including builds from an existing `Cargo.lock`**. Source replacement leaves the `source` recorded in `Cargo.lock` unchanged, so the same lock file keeps working on machines with and without Takumi Guard.

### GitHub Actions

Use the [`flatt-security/setup-takumi-guard-crates`](https://github.com/flatt-security/setup-takumi-guard-crates) action. Blocking-only requires no account or token — it configures source replacement, and your existing `cargo build` is protected (committed lock files included):

```yaml
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
      - uses: flatt-security/setup-takumi-guard-crates@v1
      - run: cargo build --locked
```

For organization-level download tracking and [breach notifications](/docs/t/guard/features/breach-notifications), add a `bot-id` and grant `id-token: write` — the action does the OIDC → short-lived-token exchange automatically, no long-lived secret in CI. GitLab CI/CD is supported too. See [the crates.io quickstart](/docs/t/guard/quickstart/crates#setup-ci) for the full pattern.

## Verify Your Setup {#verify}

Once you're set up, try adding the harmless test crate `hola-takumi`, which Takumi Guard blocks as a whole crate:

```bash
cd "$(mktemp -d)" && cargo new verify-takumi-guard && cd verify-takumi-guard && cargo add hola-takumi
```

If Takumi Guard is working, `cargo add` 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
```

For details, see ["Verify Your Setup" in the crates.io quickstart](/docs/t/guard/quickstart/crates#verify-setup).

## What You'll See When a Crate Is Blocked {#blocked-behavior}

When a single version is blocked, Takumi Guard removes it from the index, so a fresh resolve picks the newest earlier version that is not blocked. If your `Cargo.lock` already pins a blocked version, Cargo stops with an error like the following; run `cargo update -p <crate>` to move off it:

```
error: failed to select a version for the requirement `<crate> = "^1"` (locked to <version>)
```

When a whole crate is blocked, Cargo reports a 403 from Takumi Guard with the message `Takumi Guard: <crate> is blocked as a malicious package`. For details, see ["What You'll See When a Crate Is Blocked" in the crates.io quickstart](/docs/t/guard/quickstart/crates#blocked-behavior).

## Email Registration Unlocks More (Free) {#email-registration}

Register your email to receive notifications if a crate you installed is later found to be malicious. Free of charge.

:::info
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

```bash
curl -X POST https://crates.flatt.tech/api/v1/tokens \
  -H "Content-Type: application/json" \
  -d '{"email": "you@example.com"}'
```

**Step 2:** Get your API key from the welcome email. The key is included directly in the email body — no link to click.

**Step 3:** Give Cargo the token in place of `anonymous`

```bash
export CARGO_REGISTRIES_TAKUMI_GUARD_TOKEN="Bearer tg_anon_xxxxxx"
```

Cargo sends the value verbatim as the `Authorization` header, so the `Bearer ` prefix is required. Your installs are now tracked, and you will be notified if a downloaded crate is later flagged.

## Private Crates and Scope {#private-crates}

Source replacement only affects crates.io. Crates from an alternate registry, Git dependencies, and path dependencies keep working and are fetched directly, without going through Takumi Guard. `cargo install --git` and tools that download prebuilt binaries, such as `cargo-binstall`, are also outside Takumi Guard's protection. See the [crates.io quickstart](/docs/t/guard/quickstart/crates#private-crates) for details.

## Organization-Wide Management, Too {#organization-setup}

Running Takumi Guard across your team? [Installation log search](/docs/t/guard/features/installation-logs), [centralized org user token management](/docs/t/guard/features/token-management), and [breach-notification webhooks](/docs/t/guard/features/breach-notifications) are all available for organization-wide operations. Get started with a Takumi subscription (Guard enabled):

1. Go to [https://cloud.shisho.dev/hello/takumi](https://cloud.shisho.dev/hello/takumi) and sign in
2. Register your organization and subscribe to Takumi
3. Navigate to **Guard** > **Settings** from the sidebar
4. Click "Enable" to activate Guard

![Guard settings page](/docs/_md-assets/738d475b06-ui-guard-settings.png)

Once Guard is enabled, configure your CI or developer machines using the [crates.io quickstart](/docs/t/guard/quickstart/crates).
