Protect your startup's AI workloads from LLMjacking
Protect your AI workloads on Amazon Bedrock with three controls: restrict who can invoke your models, catch misuse through spend alerts, and monitor to investigate.
Consider a startup that is growing its AI initiatives. One squad prototypes an agent in a sandbox, another builds an agentic pipeline, and a customer-facing AI feature has just reached production. Each new workload shuffles between different model access quickly, often with credentials that were set up to keep things moving. Security usually sits with 1 or 2 DevOps engineers who also own CI/CD, on-call, and cost reviews, and that gap between AI adoption and security capacity is what increases the security risks a team can face.
How LLMjacking works
LLMjacking is a credential-based threat pattern where a threat actor obtains valid cloud credentials and uses them to run large-scale model inference in your account. The threat actor wants your model capacity rather than your data. They proxy commercial model capacity through your account, often reselling it to others, and your organization absorbs the cost.
A typical LLMjacking event unfolds in four stages:
- Credential exposure. A credential is exposed, for example through a public code repository, a misconfigured CI/CD pipeline, or an unmanaged sandbox account.
- Reconnaissance. The threat actor determines which models the credential can access, usually through low-volume calls that don't produce obvious errors or costs.
- Inference at scale. The threat actor sends high volumes of requests, and costs increase for as long as the activity continues.
- Delayed discovery. Without monitoring designed for AI workloads, the activity often goes unnoticed until the next billing cycle.
Start with the AWS Startup Security Baseline
Before you add AI-specific controls, make sure that the AWS Startup Security Baseline (SSB) is in place. The SSB is a set of foundational security controls for startups building on AWS that reduces the most common security risks without adding significant operational overhead. For a walkthrough of setting up your accounts and applying the SSB from day one, see Getting Started on AWS for Startups: Build Right from Day One .
Most importantly, eliminate long-lived keys for model APIs, as described in SSB controls ACCT.13 and WKLD.01 . This is the highest-impact area, because most reported LLMjacking cases begin with an exposed long-lived access key. We can't emphasise this enough: use short-term API keys or IAM role credentials for agents (covered in Control 1), and delete all unused long-lived keys and their IAM users.
The rest of this article builds on that baseline. Control 1 sets the right model access governance by restricting who can invoke Amazon Bedrock models, Control 2 adds spend and anomaly detection, and Control 3 puts detection and monitoring in place in case anything goes wrong.
Control 1: Restrict who can invoke your models
Restricting Amazon Bedrock invocation with an AWS Identity and Access Management (IAM) policy gives each agent least-privilege access and tells you who is calling the model.
Give each agent its own IAM role
Think of how you manage access for people. Each employee signs in with their own identity, so you can see who accessed which system and when. Treat an agent the same way: give it its own IAM role, and every model call it makes is attributed to that role in AWS CloudTrail .
Scope the role's policy to the specific models that the agent needs rather than
bedrock:* on "Resource": "*" , and don't grant model access to roles that don't invoke models. For examples, see Identity-based policy examples for Amazon Bedrock . If you use global cross-Region inference profiles, also see IAM policy requirements for global cross-Region inference .The IAM role defines what the agent can access. The agent's runtime infrastructure decides how the agent accesses the models. The agent's runtime infrastructure provides temporary credentials via AWS Security Token Service (AWS STS) for the role, which are rotated automatically and not stored in code. For setup steps, see the guide for your selected agent runtime:
- Amazon Bedrock AgentCore Runtime assigns an execution role to the agent and injects temporary credentials.
- Amazon Elastic Kubernetes Service (Amazon EKS): If the agent runs on Amazon EKS, use EKS Pod Identity or IAM roles for service accounts (IRSA) .
- Amazon Elastic Compute Cloud (Amazon EC2): Use an EC2 instance profile , which is an IAM role attached to the instance. The SDK picks up temporary, rotating credentials from the Instance Metadata Service. Make sure that your instances require IMDSv2 .
- AWS Lambda: Use the function's execution role . Lambda provides temporary credentials for the role to the function automatically.
Whichever runtime you choose, the agent code uses the standard AWS SDK and contains no credentials. The SDK's default credential provider chain discovers the temporary credentials injected by the runtime, so you don't need
AWS_ACCESS_KEY_ID or AWS_SECRET_ACCESS_KEY environment variables. A call to a model outside the role's policy fails with an access error. To try it, install the AWS SDK for Python (Boto3) with pip install boto3 (tested with Boto3 1.43) and run the following:import boto3from botocore.exceptions import ClientError
# No access keys anywhere. The SDK automatically picks up# the temporary credentials from the runtime environment.bedrock = boto3.client("bedrock-runtime", region_name="<region>")
try: response = bedrock.converse( modelId="global.<model-id>", messages=[{"role": "user", "content": [{"text": "Hello"}]}], ) print(response["output"]["message"]["content"][0]["text"])except ClientError as err: # A model that isn't allowed by the role's policy returns AccessDeniedException. print(err.response["Error"]["Code"])For credential handling on developer laptops, including Amazon Bedrock short-term API keys, see Calling Amazon Bedrock APIs Securely in Dev and Prod .
Complement role-based access with invocation logging and guardrails
Restricting model access to agents with their own IAM roles is the foundation. Two further settings complement it:
- Model invocation logging records each request to Amazon Bedrock with the caller's ARN and token counts. This is the telemetry that you use in Control 3, and it has to be enabled manually. See Monitor model invocation using CloudWatch Logs and Amazon S3 .
- Amazon Bedrock Guardrails applies content filtering, personally identifiable information redaction, and topic controls to model requests and responses. A guardrail with a prompt attack filter also blocks prompt injection, which an unauthorised user can use to steer a legitimate agent into inappropriate model use. It's also a prerequisite for the GuardDuty prompt injection finding in Control 3.
Control 2: Catch misuse through spend and anomaly detection
This control gives you an overview of your AI spend and alerts you when spending moves outside the norm. With the right alerts and telemetry in place, you can quickly decide whether a spike is legitimate. The Startup Security Baseline already includes AWS Budgets and AWS Cost Anomaly Detection ; this control scopes them to your AI workloads.
Configure AWS Budgets for AI spend
- Create a cost budget for model spend. In the filter, select each Amazon Bedrock service entry and Amazon SageMaker AI . Amazon Bedrock charges can appear under more than one service name, so check the Service list in Cost Explorer and include every Bedrock entry you see.
- Set alert thresholds at 50, 80, and 100 percent of expected spend. Send notifications to an Amazon Simple Notification Service (Amazon SNS) topic that reaches a named owner rather than an unmonitored mailbox. Consider a low daily threshold on sandbox accounts so you catch misuse early.
- Use AWS Budgets actions to configure an automated response. You can automatically attach a deny IAM policy when spend crosses a threshold, which acts as a circuit breaker.
Turn on Cost Anomaly Detection for your AI spend
AWS Cost Anomaly Detection uses machine learning on Cost Explorer data to flag unusual spend. Create a monitor scoped to your AI services and an alert subscription with SNS notifications for immediate delivery. It is important to note that Amazon Bedrock charges can take up to 24 hours to appear in Cost Explorer. Hence, treat cost-based alerts as a backstop, not your primary same-day detection that can be achieved with Control 3 real-time detection from GuardDuty and invocation logs.
Non-production and sandbox accounts are a common source of credential exposure because they often lack the credential hygiene applied to production. It is important that non-production accounts are given the same spend alerting as production. Replicate your budget and anomaly detection configuration into each sandbox, development, and user acceptance testing account, and automate it with your account provisioning pipeline, for example AWS Control Tower Account Factory or AWS CloudFormation templates, so that new accounts inherit the configuration by default.
Control 3: Set up detection and monitoring to investigate misuse
Spend alerts don't show the full picture. When an alert fires, you need to investigate down to the details, and telemetry shows who made the calls, with which model, and from where. Those details would also guide your remediation and next steps.
Enable GuardDuty AI Protection
Enable Amazon GuardDuty AI Protection in each account and Region that you use. GuardDuty AI Protection analyses Amazon Bedrock activity, builds a baseline of normal behaviour, and alerts you when it detects activity that deviates from that baseline. For multi-account setup, see Enabling AI Protection in multiple-account environments .

Finding type | Description |
|---|---|
Impact:IAMUser/AnomalousModelInvocation | Model invocations that deviate from the identity's baseline, such as calls from an unusual IP address, through an unusual API, or to an unusual model |
Impact:IAMUser/CostHarvesting | Computationally expensive inputs that are designed to inflate token consumption and cost |
Impact:IAMUser/PromptInjection.Direct | A direct prompt injection attempt that was detected by an Amazon Bedrock guardrail |
AI Protection is billed by the volume of CloudTrail data events it analyzes; see Amazon GuardDuty pricing . To notify your on-call engineer when a finding is generated, create an Amazon EventBridge rule with the following event pattern and an SNS topic as the target:
{ "source": ["aws.guardduty"], "detail-type": ["GuardDuty Finding"], "detail": { "type": [ "Impact:IAMUser/AnomalousModelInvocation", "Impact:IAMUser/CostHarvesting", "Impact:IAMUser/PromptInjection.Direct" ] }}Understand your AI telemetry and close the gaps
No single log source provides complete visibility into AI workloads. The following table describes what each source captures and whether you need to enable it.
Source | What it captures | Action required |
|---|---|---|
CloudTrail management events | InvokeModel , InvokeModelWithResponseStream , Converse , and ConverseStream , including which principal invoked which model, from where, and when | No action is required. The SSB trail (ACCT.07) already records these events. |
CloudTrail data events | Agent and retrieval operations such as InvokeAgent , Retrieve , RetrieveAndGenerate , InvokeFlow , ApplyGuardrail , and asynchronous invocations | Configure advanced event selectors for the Amazon Bedrock resource types that you use. See
Monitor Amazon Bedrock API calls using CloudTrail |
Model invocation logging | Request and response data and metadata for calls through the bedrock-runtime endpoint, including the caller's ARN and input and output token counts | This feature is disabled by default. Enable it in each Region that you use. See
Monitor model invocation using CloudWatch Logs and Amazon S3 |
CloudWatch Transaction Search | Trace spans for AgentCore and Amazon Bedrock agents, including individual tool calls | Enable it in each Region that you use. See
Enable Transaction Search |
Token counts from model invocation logging are often the quickest way to tell whether a usage spike is legitimate or unauthorized. If you deliver the logs to Amazon CloudWatch Logs, the following CloudWatch Logs Insights query ranks callers by token consumption:
fields identity.arn as principal, input.inputTokenCount as inTokens, output.outputTokenCount as outTokens| stats sum(inTokens) as totalInput, sum(outTokens) as totalOutput, count() as calls by principal| sort totalOutput desc
TLDR: Implementation Checklist
- Give each agent its own IAM role with access to only the Amazon Bedrock models that it needs.
- Create AI spend budgets and turn on anomaly detection, including in non-production accounts.
- Make sure that detection and monitoring are in place to capture the logs that you need to investigate.
- Enable GuardDuty AI Protection for proactive monitoring.
If you suspect unauthorized model usage, open a security support case with AWS Support from the AWS Management Console. During an active security event, the AWS Customer Incident Response Team (CIRT) can provide support. Also inform your AWS account team.
Conclusion
If you take one thing from this article, pause to consider whether these checks and balances are in place in your AWS environment. A quick configuration review now can save weeks of remediation later.
The controls that prevent LLMjacking are the same governance foundations that help your team scale AI faster. Teams that get credential hygiene, invocation governance, and spend alerting right from day one avoid security events and build the trust they need to move from sandbox to production without pause.
Resources
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article