Skip to content
Merged
2 changes: 2 additions & 0 deletions docs/reference/commands.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3045,6 +3045,8 @@ $$nemoclaw credentials add tavily-search --type tavily --credential TAVILY_API_K
Remove a provider credential from the OpenShell gateway by provider name.
After removal, re-running `$$nemoclaw onboard` re-prompts for that provider's credential.
Run `$$nemoclaw credentials list` first if you are not sure of the provider name.
OpenShell rejects provider removal while any sandbox still has that provider attached.
Destroy the affected sandbox, or detach the provider with `openshell sandbox provider detach <sandbox-name> <provider>`, before resetting the credential.

```bash
$$nemoclaw credentials reset nvidia-prod
Expand Down
2 changes: 2 additions & 0 deletions docs/security/credential-rotation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ unset TAVILY_API_KEY

Use `credentials reset` only when you need to remove an inference or web search provider before its replacement is available.
Run `$$nemoclaw credentials list` first, then pass the exact provider name from that output.
OpenShell rejects provider removal while any sandbox still has that provider attached.
Destroy the affected sandbox, or detach the provider with `openshell sandbox provider detach <sandbox-name> <provider>`, before resetting the credential.

```bash
$$nemoclaw credentials reset nvidia-prod --yes
Expand Down
36 changes: 36 additions & 0 deletions test/e2e/fixtures/bedrock-runtime-leak-scan.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

export type ForbiddenLeakPattern = [name: string, value: string];

export function bedrockRuntimeForbiddenLeakPatterns(options: {
adapterToken: string;
bedrockHostname: string;
compatibleKey: string;
}): ForbiddenLeakPattern[] {
return [
["fake user key", options.compatibleKey],
["adapter token", options.adapterToken],
["AWS bearer env name", "AWS_BEARER_TOKEN_BEDROCK"],
["raw Bedrock hostname", options.bedrockHostname],
];
}

export function findForbiddenLeaks(
text: string,
label: string,
patterns: ForbiddenLeakPattern[],
): string[] {
const locations: string[] = [];
let current = label;
for (const line of text.split("\n")) {
if (line.startsWith("@@NEMOCLAW_E2E_FILE@@ ")) {
current = line.slice("@@NEMOCLAW_E2E_FILE@@ ".length);
continue;
}
for (const [name, value] of patterns) {
if (value && line.includes(value)) locations.push(`${name}: ${current}`);
}
}
return [...new Set(locations)].sort();
}
35 changes: 9 additions & 26 deletions test/e2e/live/bedrock-runtime-compatible-anthropic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ import os from "node:os";
import path from "node:path";
import type { ArtifactSink } from "../fixtures/artifacts.ts";
import { buildAvailabilityProbeEnv } from "../fixtures/availability-env.ts";
import {
bedrockRuntimeForbiddenLeakPatterns,
findForbiddenLeaks,
} from "../fixtures/bedrock-runtime-leak-scan.ts";
import {
cleanupAcquiredResource,
cleanupExistingPath,
Expand Down Expand Up @@ -1180,25 +1184,6 @@ for proc_dir in /proc/[0-9]*; do
done
`);

function findForbiddenLeaks(
text: string,
label: string,
patterns: Array<[string, string]>,
): string[] {
const locations: string[] = [];
let current = label;
for (const line of text.split("\n")) {
if (line.startsWith("@@NEMOCLAW_E2E_FILE@@ ")) {
current = line.slice("@@NEMOCLAW_E2E_FILE@@ ".length);
continue;
}
for (const [name, value] of patterns) {
if (value && line.includes(value)) locations.push(`${name}: ${current}`);
}
}
return [...new Set(locations)].sort();
}

function isPreContractEndpointValidationRateLimit(options: {
mock: MockBedrockRuntime | undefined;
onboarding: RawRunResult;
Expand Down Expand Up @@ -1255,13 +1240,11 @@ async function assertNoBedrockLeaks(options: {
redact: (text: string, extraValues?: string[]) => string;
}): Promise<void> {
const adapterToken = readAdapterToken(options.home);
const patterns: Array<[string, string]> = [
["fake user key", COMPATIBLE_KEY],
["adapter token", adapterToken],
["AWS bearer env name", "AWS_BEARER_TOKEN_BEDROCK"],
["adapter token env name", "NEMOCLAW_BEDROCK_RUNTIME_ADAPTER_TOKEN"],
["raw Bedrock hostname", BEDROCK_HOSTNAME],
];
const patterns = bedrockRuntimeForbiddenLeakPatterns({
adapterToken,
bedrockHostname: BEDROCK_HOSTNAME,
compatibleKey: COMPATIBLE_KEY,
});
const snapshot = await runRawCommand(
"openshell",
["sandbox", "exec", "-n", SANDBOX_NAME, "--", ...sandboxShellArgs(SNAPSHOT_SCRIPT)],
Expand Down
29 changes: 28 additions & 1 deletion test/e2e/live/diagnostics.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ test("diagnostics CLI creates sanitized archives and validates sandbox/credentia
"nemoclaw debug --output creates an extractable archive without NVIDIA credential values",
"debug --sandbox accepts a registered sandbox and rejects an unknown sandbox without a partial archive",
"sandbox openclaw.json is readable through real OpenShell sandbox exec and host status includes model data",
"credentials list hides secret values and credentials reset removes the provider credential from the gateway",
"credentials list hides secret values and credentials reset is blocked while attached, then removes the provider after sandbox destruction",
],
});

Expand Down Expand Up @@ -342,10 +342,35 @@ test("diagnostics CLI creates sanitized archives and validates sandbox/credentia
});

let credentialsResetExercised = false;
let credentialsResetRejectedWhileAttached = false;
let sandboxDestroyedBeforeCredentialsReset = false;
let postResetCredentialsListRedacted = false;
let providerCredentialAbsentBeforeReset = false;
if (credentialsText.includes(hosted.providerName)) {
credentialsResetExercised = true;
const attachedReset = await host.command(
"node",
[CLI_ENTRYPOINT, "credentials", "reset", hosted.providerName, "--yes"],
{
artifactName: "diagnostics-credentials-reset-while-attached",
env,
redactionValues: [apiKey],
timeoutMs: 60_000,
},
);
expect(attachedReset.exitCode, resultText(attachedReset)).not.toBe(0);
expect(resultText(attachedReset)).toMatch(/attached to sandbox/i);
credentialsResetRejectedWhileAttached = true;

const destroy = await host.command("node", [CLI_ENTRYPOINT, SANDBOX_NAME, "destroy", "--yes"], {
artifactName: "diagnostics-nemoclaw-destroy-before-credentials-reset",
env,
redactionValues: [apiKey],
timeoutMs: 120_000,
});
expect(destroy.exitCode, resultText(destroy)).toBe(0);
sandboxDestroyedBeforeCredentialsReset = true;

const reset = await host.command(
"node",
[CLI_ENTRYPOINT, "credentials", "reset", hosted.providerName, "--yes"],
Expand Down Expand Up @@ -403,6 +428,8 @@ test("diagnostics CLI creates sanitized archives and validates sandbox/credentia
statusShowsModel: /Model/i.test(resultText(status)),
credentialsListRedacted: !credentialsText.includes(apiKey),
credentialsResetExercised,
credentialsResetRejectedWhileAttached,
sandboxDestroyedBeforeCredentialsReset,
providerCredentialAbsentBeforeReset,
postResetCredentialsListRedacted,
},
Expand Down
54 changes: 54 additions & 0 deletions test/e2e/support/bedrock-runtime-leak-scan.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

import { describe, expect, it } from "vitest";
import {
bedrockRuntimeForbiddenLeakPatterns,
findForbiddenLeaks,
} from "../fixtures/bedrock-runtime-leak-scan.ts";
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved

describe("Bedrock Runtime leak scan", () => {
const patterns = bedrockRuntimeForbiddenLeakPatterns({
adapterToken: "adapter-secret-value",
bedrockHostname: "bedrock.example.test",
compatibleKey: "user-secret-value",
});

it("allows the managed provider credential name without allowing its token value", () => {
expect(
findForbiddenLeaks(
"@@NEMOCLAW_E2E_FILE@@ /proc/42/environ\nNEMOCLAW_BEDROCK_RUNTIME_ADAPTER_TOKEN=[managed]",
"sandbox snapshot",
patterns,
),
).toEqual([]);

expect(
findForbiddenLeaks(
"@@NEMOCLAW_E2E_FILE@@ /proc/42/environ\nadapter-secret-value",
"sandbox snapshot",
patterns,
),
).toEqual(["adapter token: /proc/42/environ"]);
});

it("reports other Bedrock credentials and routing details at their source", () => {
expect(
findForbiddenLeaks(
[
"@@NEMOCLAW_E2E_FILE@@ config.json",
"user-secret-value",
"AWS_BEARER_TOKEN_BEDROCK",
"@@NEMOCLAW_E2E_FILE@@ runtime.log",
"bedrock.example.test",
].join("\n"),
"sandbox snapshot",
patterns,
),
).toEqual([
"AWS bearer env name: config.json",
"fake user key: config.json",
"raw Bedrock hostname: runtime.log",
]);
});
});
Loading