#14262·turborepo

Signed remote cache artifacts over 8 MiB are always rejected when the local cache is also enabled (regression in 2.10.13)

Author: meck93Created Sep 26, 2026Updated Sep 26, 2026

Verify canary release

  • I verified that the issue exists in the latest Turborepo canary release.

Reproduced with 2.11.5-canary.2, 2.11.4, and 2.10.13. Not reproducible with 2.10.12.

Link to code that reproduces this issue

Minimal reproduction below (four small files and a dependency-free cache server). I can publish it as a repository if that helps.

Which canary version will you have in your reproduction?

2.11.5-canary.2

Environment information

turbo 2.11.5-canary.2, 2.11.4, 2.10.13 (affected); 2.10.12 (not affected)
Linux x64, Node 24, pnpm 11.21.0
Remote cache: a minimal HTTP server that stores the request body and the x-artifact-tag header unchanged

Expected behavior

With "remoteCache": { "signature": true } and the default cache mode (local and remote read/write), an artifact that one run uploads is a remote cache hit for a later run with the same TURBO_REMOTE_CACHE_SIGNATURE_KEY.

Actual behavior

When a task's artifact is larger than 8 MiB and the same run writes both the local and the remote cache, the uploaded x-artifact-tag does not cover the artifact body.

A later run downloads the artifact, rejects the tag, and executes the task.

The output shows only cache miss, executing <hash>. No warning mentions the signature.

Case (read with an empty local cache, TURBO_CACHE=local:rw,remote:r) 2.10.12 2.10.13 2.11.4 2.11.5-canary.2
20 MiB artifact, written with local:rw,remote:rw hit miss miss miss
21 MiB artifact, written with remote:rw (no local write) hit hit hit hit
4 MiB artifact, written with local:rw,remote:rw hit hit hit hit

For the failing case, the stored tag matches HMAC-SHA256 over the message fields and the body length without the body bytes, and it does not match the same computation with the body (checked on 2.11.4):

field(x) = u64_le(len(x)) || x
stored tag == HMAC(key, field("artifact-signature:v2") || field(hash) || field(team_id) || u64_le(body_len))            -> true
stored tag == HMAC(key, field("artifact-signature:v2") || field(hash) || field(team_id) || u64_le(body_len) || body)    -> false

To Reproduce

package.json:

json
{ "name": "turbo-sig-repro", "private": true, "packageManager": "[email protected]", "devDependencies": { "turbo": "2.11.4" } }

pnpm-workspace.yaml:

yaml
packages:
  - pkg

turbo.json:

json
{ "$schema": "https://turborepo.com/schema.json", "remoteCache": { "signature": true },
  "tasks": { "build": { "outputs": ["dist/**"], "env": ["OUTPUT_MIB"] } } }

pkg/package.json and pkg/gen.mjs (writes OUTPUT_MIB MiB of incompressible data):

json
{ "name": "pkg", "private": true, "scripts": { "build": "node gen.mjs" } }
javascript
import { mkdirSync, writeFileSync } from 'node:fs'
import { createHash } from 'node:crypto'
const mib = Number(process.env.OUTPUT_MIB ?? 20)
const out = Buffer.alloc(mib * 1024 * 1024)
let block = createHash('sha256').update(String(mib)).digest()
for (let i = 0; i < out.length; i += 32) { block = createHash('sha256').update(block).digest(); block.copy(out, i) }
mkdirSync('dist', { recursive: true }); writeFileSync('dist/out.bin', out)

server.mjs (in-memory cache that stores the body and tag unchanged):

javascript
import { createServer } from 'node:http'
const store = new Map()
createServer((req, res) => {
  const url = new URL(req.url, 'http://x')
  const m = url.pathname.match(/^\/v8\/artifacts\/([0-9a-f]+)$/)
  if (url.pathname === '/v8/artifacts/status') return res.end('{"status":"enabled"}')
  if (url.pathname === '/v8/artifacts/events') { req.resume(); return res.end('{}') }
  if (!m) { res.statusCode = 404; return res.end() }
  if (req.method === 'PUT') {
    const chunks = []
    req.on('data', (c) => chunks.push(c)).on('end', () => {
      store.set(m[1], { body: Buffer.concat(chunks), tag: req.headers['x-artifact-tag'] })
      res.statusCode = 202; res.end('{}')
    })
    return
  }
  const entry = store.get(m[1])
  if (!entry) { res.statusCode = 404; return res.end() }
  res.setHeader('content-length', entry.body.length)
  if (entry.tag) res.setHeader('x-artifact-tag', entry.tag)
  res.end(req.method === 'HEAD' ? undefined : entry.body)
}).listen(3918, '127.0.0.1')

Steps (git init and commit first):

bash
pnpm install
node server.mjs &
export TURBO_API=http://127.0.0.1:3918 TURBO_TEAM=repro TURBO_TOKEN=repro-token
export TURBO_REMOTE_CACHE_SIGNATURE_KEY=kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk

# 1. Write: local and remote (the default). Artifact is about 20 MiB.
OUTPUT_MIB=20 TURBO_CACHE=local:rw,remote:rw TURBO_CACHE_DIR=$(mktemp -d) pnpm exec turbo run build

# 2. Read with an empty local cache: expected "cache hit", actual "cache miss, executing <hash>".
OUTPUT_MIB=20 TURBO_CACHE=local:rw,remote:r TURBO_CACHE_DIR=$(mktemp -d) pnpm exec turbo run build

Repeating step 1 with TURBO_CACHE=remote:rw, or with OUTPUT_MIB=4, makes step 2 a hit.

Root cause

The regression comes from #14012 ("Build cache archives once for local and remote writes"), merged on 2026-09-09 and first released in 2.10.13.

All references are to crates/turborepo-cache/src at v2.11.4:

  1. multiplexer.rs, put: when local and remote writes are both enabled, the archive is built once as an ArtifactBody. fs.put_archive(...) runs first, then http.put_body(key, body, duration).

  2. fs.rs, put_archive: writes the local archive with archive.copy_to(&mut buffered).

  3. artifact_body.rs, copy_to: std::io::copy(&mut self.reader()?, &mut writer). For OnDisk, reader() does file.try_clone(), seeks the clone to 0, and reads it to the end. try_clone duplicates the file descriptor, and a duplicated descriptor shares the file offset with the original. After the local write, the original File is at EOF. A comment in stream() says that "try_clone hands us an independent handle". The handle is independent, but its offset is not.

  4. http.rs, put_body → artifact_body.rs, generate_tag: the OnDisk branch passes the original file to generate_tag_reader, which reads from the current offset (EOF) and gets 0 bytes:

    rust
    ArtifactBody::OnDisk(file) => {
        signer.generate_tag_reader(hash.as_bytes(), file, self.len() as u64)
    }

    The tag therefore covers the fields and the body length, but not the body.

  5. The upload itself is correct, because stream() seeks to 0 before it reads. On download, fetch verifies the full body with a streaming tag, so the tag does not match and the artifact is rejected.

This affects only OnDisk bodies, which are artifacts over ARTIFACT_MEMORY_THRESHOLD (8 MiB). With remote:rw only, nothing reads the file before generate_tag, so the offset is still 0 and the tag is correct.

Impact: with signing on, every artifact over 8 MiB is uploaded but can never be used. This is not a signature bypass: forged bodies are still rejected, because the reader verifies the full body.

Suggested fix

Sign from a rewound reader instead of the shared handle:

rust
ArtifactBody::OnDisk(_) => {
    signer.generate_tag_reader(hash.as_bytes(), self.reader()?, self.len() as u64)
}

Because all clones share one offset, two consumers that read at the same time can still interfere with each other. Positional reads (FileExt::read_at / seek_read), or opening a new handle per consumer, would remove that class of bug. A regression test could upload a signed artifact over 8 MiB with local and remote writes enabled, then fetch it with an empty local cache.

Additional context

We found this with a self-hosted cache and a Next.js build artifact of about 240 MiB.

Unrelated side note, which we can file separately: the turbo binary contains the message "TURBO_SIGNATURE should be either 1 or 0", but on 2.11.4 neither TURBO_SIGNATURE=1 nor TURBO_SIGNATURE=true changes turbo config ("signature": false). Only turbo.json turns signing on.