aws/agent-toolkit-for-aws/agents-harden
Claude Code and agent skill by aws/agent-toolkit-for-aws
- community
Checking that the SKILL.md file is still in the repository.
Use when preparing your agent for production — IAM scoping, inbound auth (JWT, SigV4), secrets management, cold start optimization, session lifecycle, rate limiting, input validation, and quota guidance. Triggers on: "production checklist", "harden agent", "production ready", "secure agent", "inbound auth", "going live", "cold start optimization", "session lifecycle", "StopRuntimeSession", "quota", "throttling", "maxVms", "rate limit", "security audit of outbound API calls", "gateway target audit for production", "restrict who can call", "lock down endpoint", "only our app can call". Not for Cedar tool-restriction policies — use agents-connect. Not for quality measurement — use agents-optimize. Not for outbound credential storage or API key wiring — use agents-connect. Not for A2A agent-to-agent auth — use agents-build. Cold start observation and diagnosis (not optimization) routes to agents-debug.
Install
npx vskill@latest install aws/agent-toolkit-for-aws/agents-hardenSKILL.md
The same SKILL.md was published earlier as aws/agent-toolkit-for-aws/agents-harden.
harden
Prepare your AgentCore agent for production — security, reliability, and performance.
When to use
- You're about to take an agent to production
- You want a checklist of what to review before launch
- You want to restrict who can call your agent
- You want to scope down IAM permissions from the defaults
- You're hitting throttling or quota errors (loads `references/limits.md`)
- You need to tune session lifecycle for your workload
- You're running long-running background work in your agent
Input
No arguments required. The skill reads your project config and produces a checklist with specific findings for your project.
Process
Step 0: Verify CLI version
Run agentcore --version. This skill requires v0.9.0 or later. If the version is older, tell the developer to run agentcore update before proceeding.
Step 1: Read the project
Read agentcore/agentcore.json to understand:
- What resources are configured (memory, gateway, credentials, evaluators)
- What framework is being used
- What network mode is configured (PUBLIC or VPC)
Step 2: Run through the checklist
Work through each category and report findings specific to the project.
IAM: Scope down permissions
The auto-created execution role has broad Bedrock access (arn:aws:bedrock:*::foundation-model/*). For production, scope it to the specific models your agent uses.
Check the current execution role:
Recommended production Bedrock policy:
Replace the resource ARN with the specific model(s) your agent uses.
ECR access: Scope to your specific repository:
Trust policy: Verify the execution role's trust policy is scoped to your account:
Runtime resource-based policies (API-only): For fine-grained control over which principals can invoke your runtime — beyond what IAM roles and JWT auth provide — use PutAgentRuntimeResourcePolicy via boto3. This is not exposed in the CLI or agentcore.json. Use the awsknowledge MCP server if available to look up the current API shape.
Shell Access: Scope InvokeAgentRuntimeCommand separately
If your project uses InvokeAgentRuntimeCommand (see `agents-build/references/integrate.md`), audit its IAM permissions separately from InvokeAgentRuntime. The two actions have different blast radii: InvokeAgentRuntimeCommand is arbitrary shell execution inside a live microVM with the runtime's full execution role — callers can read/write the filesystem, reach any network resource the agent can reach, and access the execution role's credentials.
Check which principals have the permission:
Alternatively, use the IAM console: IAM → Policies → Filter by type: Customer managed → search for InvokeAgentRuntimeCommand in the policy JSON editor.
Separate IAM policy for command callers — keep this distinct from the policy granting InvokeAgentRuntime:
Enable CloudTrail alerting. Create an EventBridge rule to notify your security team when InvokeAgentRuntimeCommand is called:
If commands are constructed from user input anywhere in calling code: validate before passing — reject strings containing &&, ;, $(...), backticks, |, or other shell metacharacters.
Inbound auth: Control who can call your agent
By default, agents use AWS IAM (SigV4) for inbound auth. For production, verify this is configured correctly.
Check current auth config:
Options:
AWS_IAM (default) — callers must sign requests with SigV4. Good for internal services and AWS-native clients.
CUSTOM_JWT — callers present a JWT from your identity provider. Good for web/mobile apps and external clients.
[!WARNING]Never use--authorizer-type NONEin production. It allows unauthenticated accessto your agent — anyone with the endpoint URL can invoke it. Always use AWS_IAM orCUSTOM_JWT. If you see NONE in production, change it immediately.
Choosing allowedClients vs allowedAudience
This is the most common JWT misconfiguration. The right choice depends on what's inside the token your IdP issues.
Decode a sample token (at your IdP or with jwt.io) and look at the payload:
- Token has a
client_idclaim, noaudclaim → configure `allowedClients` on the runtime - Token has an
audclaim → configure `allowedAudience` on the runtime - Token has both → use
allowedAudience. Theaudclaim is the standard OIDC audience field; use that as the primary check.
If you pick the wrong one, invocations return 403 even with a valid token — the runtime is validating against a claim the token doesn't have.
Issuer ↔ discovery URL prefix requirement
AgentCore enforces the OIDC discovery spec (RFC 8414 §3): the issuer value in the discovery document must be a URL prefix of the discovery endpoint.
That means if your discovery URL is https://qa.example.com/.well-known/openid-configuration, the issuer field in that document must start with https://qa.example.com. If the document advertises an issuer like https://example.com (no subdomain), validation fails.
Some enterprise IdPs (PingFederate, Paylocity, some Keycloak setups) host the discovery endpoint on an environment-specific subdomain while advertising a production-level issuer. This pattern is incompatible with the RFC 8414 prefix rule.
Fix options:
- Align the IdP's discovery endpoint with its issuer — serve discovery from the same origin as the issuer.
- Point the runtime at the actual discovery URL domain — configure the runtime's discovery URL with the subdomain that matches the token's issuer.
Debugging JWT auth failures
When invocations fail with 403, narrow down which check is failing.
`Authorization method mismatch` — the runtime's auth type and the request's auth type don't match. Two cases:
- The runtime is configured for
AWS_IAM(or no authorizer) but the caller is sending a Bearer token → reconfigure the runtime forCUSTOM_JWT, or have the caller use SigV4. - The runtime is configured for
CUSTOM_JWTbut the caller's request is being SigV4-signed → likely the SDK or environment is injecting SigV4 headers alongside the Bearer token. Check forX-Amz-Date,X-Amz-Security-Token, orAuthorization: AWS4-HMAC-SHA256in the outbound request. Remove the SigV4 path and send only the Bearer token.
`Invalid inbound token` (or similar) — the token was rejected by the JWT validator. Walk through these in order:
- Issuer ↔ discovery URL prefix (above) — verify the token's
issclaim matches the discovery URL's origin - `allowedClients` vs `allowedAudience` — is the runtime configured for the right claim for your token format?
- JWKS reachability — can AgentCore reach the
jwks_urilisted in the discovery document? It must be publicly reachable. - Token expired — decode the token, check
expagainst now - Signing algorithm support — some IdPs sign with algorithms (PS256, ES384, etc.) that aren't universally supported. Check your IdP's supported algorithms and switch to RS256 if compatibility is the issue.
Only after ruling all of those out should you treat it as a service-side issue.
Error handling: Fail gracefully
Check that your agent code handles errors without exposing internal details:
Check for: bare except blocks that swallow errors silently, error messages that expose stack traces or internal details to callers, missing error handling in tool call code.
Input validation and rate limiting
Agent entrypoints receive arbitrary payloads from callers. Validate inputs before processing:
What to validate:
- Required fields are present and have the expected type
- String inputs don't exceed reasonable length limits (prevents token-bombing the model)
- Numeric inputs are within expected ranges
- User-provided IDs (actor_id, session_id) match expected formats
Rate limiting: AgentCore Runtime has built-in invocation rate limits (default 25 TPS per agent — see `references/limits.md`). For application-level rate limiting (per-user, per-tenant), implement it in your calling application or API Gateway layer, not in the agent code itself. The agent should assume it's already been rate-limited by the time a request reaches it.
Secrets: No credentials in code, no secrets in runtime env vars
Two failure modes to check for:
1. Hardcoded secrets in agent code
2. Secrets pulled from runtime environment variables
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingplugins/aws-agents/skills/agents-harden/SKILL.md
Popularity
- Repository stars
- 2,206
- Repository forks
- 214
- 7-day trend score
- 38
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/aws/agent-toolkit-for-aws/agents-harden)