
Auditing MCP Servers for Shell Access and Unnecessary AWS Permissions
On this page
What the MCP security reports claim—and what remains unverified
This post is a practical guide to auditing MCP servers for hidden shell access and unnecessary AWS permissions, with boundary tables, reproducible fixtures, and a prioritized fix list. It was drafted with AI assistance; the disclosure is handled at the post level rather than in an inline component. Everything below I have not actually run is labeled expected, not observed; an AI-usage score is not evidence.
This started from coverage published on December 5, 2026. CyberSecurityNews ran a headline claiming MCP security flaws "could let hackers run hidden commands and access AWS cloud resources." Newsbytes.PH ran a separate piece the same day quoting a cybersecurity executive warning against giving AI agents broad system access. Both are secondary sources. The supplied material for each is a headline plus a one-line summary—no technical detail.
Here is the evidence boundary:
| Question | Answer from the supplied material |
|---|---|
| Which MCP servers or SDKs are affected? | Not identified |
| Affected versions? | Not identified |
| CVE identifiers? | None given |
| Exploit prerequisites? | Not described |
| Confirmed active exploitation? | Not claimed |
| Original research or advisory? | Not referenced in the snippets |
That is not a knock on the reporting—headline feeds carry headline-level summaries. But "could allow" is a potential-impact statement, and I cannot upgrade it into a confirmed vulnerability without an advisory, a CVE record, or my own reproduction. I have none of those. What I do have is the architecture those headlines point at, and that architecture is worth auditing whether or not this specific report resolves into a named CVE.
My position: stop treating MCP tool sandboxing as a prompting problem. Tool allowlists and human approval prompts are useful, but they cannot compensate for an MCP server process that already holds general-purpose shell access and ambient cloud credentials. Fix the authority first. Everything else is a speed bump.
Map trust boundaries between MCP agent intent and operating-system authority
A typical MCP server workflow is short, and each hop crosses a trust boundary:
- User request — untrusted text from a human, a page, or another agent.
- Model tool selection — the model picks an advertised tool and produces arguments. Untrusted output, untrusted input.
- Server-side argument handling — your handler receives a JSON object. This is the first place you get to say no.
- Subprocess or AWS SDK operation — the handler converts arguments into an OS action or an API call. This is where authority is actually exercised.
- Returned tool result — data flows back to the model, which will happily treat it as instructions later.
The mistake I see repeatedly is collapsing steps 2 and 4. An advertised tool schema is a description of a shape, nothing more. It does not establish authorization. It does not constrain subprocess behavior. It does not scope AWS permissions. A schema that says {"command": {"type": "string"}} is a schema that says "send me anything."
Before touching code, build a boundary table per tool. It is the single highest-value artifact of the audit:
| Tool | Accepted inputs | Execution sink | Execution identity | Reachable resources | Approval required |
|---|---|---|---|---|---|
list_reports | kind enum | fs.readdir | server process UID | /srv/mcp/workspace | no |
run_report | kind, name | spawn (no shell) | server process UID | workspace + /usr/bin/node | yes |
s3_metadata | bucket, key | GetObjectAttributes | task role | one bucket prefix | no |
admin_shell | command | exec with shell: true | server process UID | everything the process can reach | "yes" (meaningless) |
That last row is the finding, regardless of what any advisory says. A tool with a free-form command string and shell: true is remote code execution behind a JSON-RPC endpoint. The approval prompt is theater once the process is that privileged.
Set up a safe, reproducible MCP audit environment
I keep this boring on purpose:
- An MCP server I own—either a first-party one or a local fixture—never a third party's production endpoint.
- A disposable workspace directory with synthetic files, no real customer data, no real config.
- Recorded versions: Node.js (
node -v), the MCP SDK inpackage.json,@aws-sdk/*versions, OS and kernel (uname -a). - Shell tests run local and credential-free. Explicitly
env -u AWS_ACCESS_KEY_ID -u AWS_SECRET_ACCESS_KEY -u AWS_SESSION_TOKEN -u AWS_PROFILEso a stray credential can't turn a marker-file test into a real API call. - AWS checks optional, behind a flag, restricted to a dedicated test account with a dedicated test role, and read-only.
Define evidence collection before running anything, because debug logs love secrets:
- sanitized tool arguments (length-capped, control characters escaped);
- the authorization decision and the policy that produced it;
- subprocess launch records: resolved executable path, argv array,
shellflag, cwd, environment key names only; - AWS request IDs from SDK middleware (
$metadata.requestId) — never the signed headers.
Do not log process.env or full child environments. AWS_SESSION_TOKEN and AWS_SECRET_ACCESS_KEY are values you will paste into a ticket by accident. Log key names, not values.
Find shell access hidden behind ordinary-looking MCP tools
Start with a static sweep. The tools that hurt rarely have "shell" in the name—they're called run_report, convert_document, fetch_url, git_status.
rg -n --glob '!node_modules' --glob '!dist' \
-e 'child_process' -e 'execSync' -e 'spawnSync' -e 'execFile' \
-e 'shell:\s*true' -e '\bexec\(' -e '\bexecSync\(' \
servers/ packages/
Two things to remember about the hits:
- A hit is not a finding.
execFilewith a fixed binary and an array is fine.execwith concatenation is not. You have to follow the data flow from the tool argument to the sink. - The compiler will not help you.
execandexecFilehave nearly identical call sites and completely different threat models.
Distinguish four failure modes, because the fixes differ:
| Mode | Example | Fix |
|---|---|---|
| Shell interpretation | exec("report " + name) | remove shell, pass argv array |
| Executable selection | spawn(userProvidedPath) | fixed allowlisted binary path |
| Argument injection | spawn("git", ["--upload-pack=" + arg]) | validate operands, use -- |
| Intentionally arbitrary | admin_shell tool | delete it, or move it behind a real sandbox |
Here's a minimal vulnerable fixture, deliberately wrong:
import { exec } from "node:child_process";
// Audit fixture: builds a shell command string from a model-supplied value.
export function runReport({ name }) {
return new Promise((resolve) => {
exec("node scripts/report.js " + name, (err, stdout) => {
resolve({ ok: !err, stdout, code: err ? err.code : 0 });
});
});
}And a harmless regression test that proves shell interpretation without touching anything but a marker file:
import { existsSync, rmSync } from "node:fs";
const MARKER = "/tmp/mcp-audit-marker";
rmSync(MARKER, { force: true });
const result = await runReport({ name: "daily; touch " + MARKER });
console.log("tool result:", JSON.stringify(result));
console.log("marker created:", existsSync(MARKER));The vulnerable fixture should produce (this is what it is designed to emit, not output I captured from a vendor system):
tool result: {"ok":true,"stdout":"","code":0}
marker created: true
The same test against a hardened handler should produce:
tool result: {"ok":false,"error":"invalid_name"}
marker created: false
Audit limits, stated up front. A grep hit needs data-flow review before it becomes a finding. Passing one metacharacter test does not prove the handler is safe—--upload-pack, -oProxyCommand, --output, and @file argument conventions are all argument-injection paths that never touch a semicolon. And if your handler calls a wrapper script that itself calls sh -c, the test you just ran tells you nothing about the inner layer.
Replace shell command strings with narrow server-side operations
The fix is not better escaping. The fix is that the model never contributes to executable selection or shell syntax.
import { spawn } from "node:child_process";
const REPORT_ROOT = "/srv/mcp/workspace";
const ALLOWED_KINDS = new Set(["daily", "weekly"]);
export async function runReport({ kind, name }) {
if (!ALLOWED_KINDS.has(kind)) {
return { ok: false, error: "operation_not_allowed" };
}
if (typeof name !== "string" || !/^[a-z0-9_-]{1,32}$/.test(name)) {
return { ok: false, error: "invalid_name" };
}
// "--" ends option parsing; name can no longer be read as a flag.
const args = ["/srv/mcp/bin/report.js", kind, "--", name];
return await new Promise((resolve) => {
const child = spawn("/usr/bin/node", args, {
shell: false,
cwd: path.join(REPORT_ROOT, kind),
env: { PATH: "/usr/bin:/bin", NODE_ENV: "production" },
timeout: 2000,
maxBuffer: 64 * 1024,
stdio: ["ignore", "pipe", "pipe"],
});
let out = "";
child.stdout.on("data", (chunk) => {
if (out.length < 65536) out += chunk.toString("utf8");
});
child.on("error", () => resolve({ ok: false, error: "spawn_failed" }));
child.on("close", (code, signal) => {
if (signal) return resolve({ ok: false, error: "timeout", signal });
resolve({ ok: code === 0, code, output: out.slice(0, 4096) });
});
});
}Points worth defending:
shell: falseis the default, but I set it explicitly so a future edit has to delete a line to reintroduce the bug.--is the end-of-options separator, and it only works becausereport.jsdoesn't reinterpret it. Verify that; don't assume.- The regex is operation-specific allowlisting, not sanitization. It exists to reject nonsense early and give a clean error, not to make execution safe.
envis a minimal allowlist. Passingprocess.envhands the child everyAWS_*andGITHUB_TOKENthe server holds.cwdis pinned,timeoutbounds runtime,maxBuffer-style capping bounds output.
Expected regression output across the four cases:
allowed {"ok":true,"code":0,"output":"report daily: 12 rows"}
malformed {"ok":false,"error":"invalid_name"}
bad path {"ok":false,"error":"operation_not_allowed"}
timeout {"ok":false,"error":"timeout","signal":"SIGTERM"}
Shell-free execution still requires privilege containment. The child inherits the server's UID, so it can read anything that UID can read. Filesystem restrictions (container read-only root, seccomp profile, narrow bind mounts, no network namespace egress except what the task needs) are what actually bound the blast radius. The code above removes shell interpretation; it does not remove authority.
Determine which AWS identity your MCP server actually uses
For the AWS SDK for JavaScript v3, the default provider chain considers—roughly in order—explicitly passed credentials, environment variables (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_SESSION_TOKEN), SSO and shared ~/.aws/credentials / ~/.aws/config profiles, web identity token files, ECS container credential endpoints, and EC2 instance metadata. Long-lived keys in the environment outrank the workload role you thought you were using. That is the whole reason I audit the resolved identity before writing any policy.
Optional, and only in an account you own:
aws sts get-caller-identity --query 'Arn' --output text
Illustrative expected output:
arn:aws:iam::111122223333:role/mcp-audit-tool-role
That command tells you what your CLI resolved. It does not prove the MCP server resolves the same identity. The server may run in a different container, with a different AWS_PROFILE, or with credentials injected by a supervisor. Confirm from inside the server process (same env, same working directory) and compare ARNs by request ID, never by printing key material.
Identity is also not permission. Effective authority comes from identity policies, resource-based policies, session policies, permissions boundaries, service control policies, and resource control policies—with explicit deny winning everywhere. IAM's evaluation logic is documented and worth reading once properly. Notably, a same-account resource-based policy can grant access that identity policies alone would not, so "I only gave the role S3 read" is an incomplete statement until you have looked at bucket policies too.
The impact chain is conditional: MCP connectivity alone means nothing. Hidden command execution combined with a role that can read secrets, assume other roles, or exfiltrate data means a lot. Ask what the resolved identity can reach, not whether it can authenticate—and treat every unnecessary AWS permission as part of the attack surface.
Scope AWS permissions to the MCP tool's actual job
Take one concrete tool: s3_metadata, which returns object metadata for a sample report. It calls HeadObject (or GetObjectAttributes if you want checksums). Map that to exactly one IAM action and exactly one object ARN.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "ReadOnlyOneObject",
"Effect": "Allow",
"Action": "s3:GetObjectAttributes",
"Resource": "arn:aws:s3:::hackyjs-mcp-audit-bucket/reports/2026/q4-sample.bin"
},
{
"Sid": "ListOnlyThatPrefix",
"Effect": "Allow",
"Action": "s3:ListBucket",
"Resource": "arn:aws:s3:::hackyjs-mcp-audit-bucket",
"Condition": { "StringLike": { "s3:prefix": "reports/2026/*" } }
}
]
}No s3:*. No Resource: "*". No iam:PassRole. The verification matrix:
| Test | Expected decision | Why |
|---|---|---|
GetObjectAttributes on reports/2026/q4-sample.bin | Allowed | matches action + ARN |
GetObjectAttributes on reports/2026/q1-sample.bin | Implicit deny | ARN not in policy |
PutObject on the same object | Implicit deny | no allow statement |
AssumeRole anywhere | Implicit deny | no allow statement |
Simulation first, live second:
aws iam simulate-principal-policy \
--policy-source-arn arn:aws:iam::111122223333:role/mcp-audit-tool-role \
--action-names s3:GetObjectAttributes s3:PutObject \
--resource-arns arn:aws:s3:::hackyjs-mcp-audit-bucket/reports/2026/q4-sample.bin
Illustrative expected shape:
s3:GetObjectAttributes allowed
s3:PutObject implicitDeny
Simulation limits matter: the IAM policy simulator does not evaluate every policy type in every path (SCPs and boundaries have historically been out of scope or partial), it will not resolve conditions unless you supply the context keys, and it ignores resource-based policies unless you point at them. Treat "allowed" as a hypothesis. Confirm it only with non-destructive calls in the sandbox.
Last piece: keep unrelated credentials out of subprocesses. A child_process spawned with the full environment is a credential leak waiting for a console.log. And remember that short-lived, workload-specific roles still bite if they are broad—temporary AdministratorAccess is temporary AdministratorAccess.
Make MCP tool allowlists and approval gates enforceable
Hiding a tool from tools/list is not access control. If a model can name a handler, and the handler dispatches without checking, the tool list is decoration. Enforce at dispatch:
const TABLE = {
list_reports: { op: "fs.list", allow: (ctx) => ctx.role === "analyst" || ctx.role === "operator" },
run_report: { op: "proc.exec.report", allow: (ctx) => ctx.role === "operator" },
s3_metadata: { op: "aws.s3.readmeta", allow: (ctx) => ctx.role !== "anonymous" },
};
export function dispatch(toolName, args, ctx) {
const entry = Object.hasOwn(TABLE, toolName) ? TABLE[toolName] : null;
if (!entry) throw new Error("unknown_tool");
if (!entry.allow(ctx)) throw new Error("forbidden");
if (entry.op === "proc.exec.report") return runReport(args);
if (entry.op === "aws.s3.readmeta") return s3Metadata(args);
if (entry.op === "fs.list") return listReports(args);
throw new Error("unmapped_op");
}Approval has to be bound to something concrete, or it is a checkbox. Bind it to the normalized operation, exact arguments, target resource, execution identity, and an expiry, then make it single-use:
import { createHmac, randomUUID, timingSafeEqual } from "node:crypto";
const KEY = process.env.APPROVAL_HMAC_KEY;
const used = new Set();
export function mintApproval(call) {
const body = {
op: call.op,
args: call.args,
target: call.target,
identity: call.identity,
exp: Date.now() + 5 * 60 * 1000,
nonce: randomUUID(),
};
const payload = JSON.stringify(body);
return { payload, mac: createHmac("sha256", KEY).update(payload).digest("hex") };
}
export function checkApproval(call, approval) {
const expect = createHmac("sha256", KEY).update(approval.payload).digest("hex");
const a = Buffer.from(expect, "hex");
const b = Buffer.from(approval.mac, "hex");
if (a.length !== b.length || !timingSafeEqual(a, b)) return "bad_mac";
const body = JSON.parse(approval.payload);
if (used.has(body.nonce)) return "replayed";
if (Date.now() > body.exp) return "expired";
if (body.op !== call.op) return "op_mismatch";
if (body.target !== call.target) return "target_mismatch";
if (body.identity !== call.identity) return "identity_mismatch";
if (JSON.stringify(body.args) !== JSON.stringify(call.args)) return "args_mismatch";
used.add(body.nonce);
return "ok";
}A caveat worth writing into the code review: comparing JSON.stringify output depends on key order, so normalize arguments into a canonical form before hashing and comparing. Otherwise you ship a gate that rejects legitimate calls and, worse, tempts someone to loosen it.
Expected test results for the gate:
| Case | Expected result |
|---|---|
| Approval minted, same op and args | ok |
Argument changed after approval (key swapped) | args_mismatch |
| Approval replayed | replayed |
Approval for s3_metadata used on run_report | op_mismatch |
| Expired approval | expired |
Two residual risks I want on record. First, approval is a supplemental control, not a sandbox—if the underlying process has shell access, a convincing argument string can still be approved by a tired human. Second, read operations leak: a "safe" read tool scoped to one bucket still exposes confidential data if the model is induced to read it. Least privilege applies to reads too.
Turn the MCP audit into a prioritized fix list
Rank by what removes authority, not by what's easy:
- Delete arbitrary execution paths. Remove
admin_shell-style tools, genericcommandparameters, andshell: true. No allowlist compensates for these. - Reduce reachable AWS authority. Replace broad roles with one-action, one-ARN policies; separate the tool's role from any human's role; keep unrelated credentials out of child environments.
- Strengthen dispatch authorization. Move checks from
tools/listinto the handler, cover alternate handlers, and fail closed on unknown tools. - Add approvals and monitoring. Bound approvals to exact calls, log decisions with request IDs, and alert on denied operations and on new tool names appearing.
The evidence table is what makes the report actionable:
| Finding | Input | Boundary crossed | Expected/captured result | Impact | Fix | Regression test |
|---|---|---|---|---|---|---|
| Shell metacharacters interpreted | name = "daily; touch /tmp/x" | argument → shell | marker created | arbitrary command as server UID | shell: false + argv array | marker must not exist |
Free-form command tool | any string | tool → OS | full exec as server UID | full host compromise | remove tool | unknown_tool |
| Broad S3 role | bucket, key | tool → AWS | Allowed on out-of-scope object | data exposure | one-action, one-ARN policy | implicitDeny on out-of-scope |
| Approval not bound to args | mutated key | approval → privileged call | ok (bad) | approve-one, do-another | HMAC over normalized args | args_mismatch |
Coverage statement. The supplied reports say that MCP flaws could allow hidden command execution and access to AWS cloud resources, and that an executive warned against broad agent system access. That is the full extent of what is sourced—no implementations, versions, or CVE identifiers were provided, and I have not verified the underlying research. Everything above is an audit method with illustrative fixtures and expected outputs; none were run against a named vendor server. What you reproduce in your own environment is the only evidence that counts for your deployment. Two untested assumptions worth flagging: that your MCP host actually routes every call through your dispatch table, and that your platform team's role boundaries are as tight as the policy documents suggest.
Further Reading
Supplied secondary sources
- CyberSecurityNews: MCP Security Flaws Could Let Hackers Run Hidden Commands and Access AWS Cloud Resources — December 5, 2026, headline-level summary only.
- Newsbytes.PH: Cybersecurity exec warns against giving AI agents broad system access — December 5, 2026.
I did not locate an original advisory or CVE record behind either report, so I am not inventing one.
Primary documentation
- MCP specification: server tools — what a tool schema does and does not guarantee.
- MCP specification: security best practices — the protocol-level baseline.
- Node.js
child_process—shell,timeout,maxBuffer, and theexecvsexecFiledistinction. - AWS SDK for JavaScript v3: setting credentials in Node.js — the provider chain you are actually resolving.
- IAM policy evaluation logic — explicit deny, boundaries, session policies.
- Testing IAM policies with the IAM policy simulator — and its documented limitations.
aws sts get-caller-identity— the identity check, with the caveat above.
More posts

TrojanPony and the Trust Boundary Between Repo Files and Agent Command Execution
Dark Reading's TrojanPony campaign shows how repository-borne malware spreads across 400+ repos by exploiting AI coding agents that trust workspace files, and this walkthrough maps the trust boundary between repo contents and automatic command execution with concrete hardening steps.

Auditing Developer Tools Like Bito for Local Shell Command Execution
Akamai reports a Bito vulnerability exposing 950,000 installs to local shell command execution, prompting a developer-tool security checklist covering extension inventory, process permissions, credential exposure, and update verification.

Cost per Successful Agent Task with Qwen4-35B-A3B: Testing Quantization and CPU Offload Limits on 8GB GPUs
A reproducible cost-per-successful-task evaluation of Qwen4-35B-A3B on 8GB GPUs, measuring how quantization and CPU offload affect memory, latency, throughput, and agent reliability across context lengths.
Loading comments…