Potential Abuse of Resources by High Token Count and Large Response Sizes

Detects potential resource exhaustion or data breach attempts by monitoring for users who consistently generate high input token counts, submit numerous requests, and receive large responses. This behavior could indicate an attempt to overload the system or extract an unusually large amount of data, possibly revealing sensitive information or causing service disruptions.

Elastic rule (View on GitHub)

  1[metadata]
  2creation_date = "2024/05/04"
  3maturity = "production"
  4updated_date = "2025/07/16"
  5
  6[rule]
  7author = ["Elastic"]
  8description = """
  9Detects potential resource exhaustion or data breach attempts by monitoring for users who consistently generate high
 10input token counts, submit numerous requests, and receive large responses. This behavior could indicate an attempt to
 11overload the system or extract an unusually large amount of data, possibly revealing sensitive information or causing
 12service disruptions.
 13"""
 14false_positives = ["Authorized heavy usage of the system that is business justified and monitored."]
 15from = "now-60m"
 16interval = "10m"
 17language = "esql"
 18license = "Elastic License v2"
 19name = "Potential Abuse of Resources by High Token Count and Large Response Sizes"
 20note = """## Triage and analysis
 21
 22### Investigating Potential Abuse of Resources by High Token Count and Large Response Sizes
 23
 24Amazon Bedrock is AWS’s managed service that enables developers to build and scale generative AI applications using large foundation models (FMs) from top providers.
 25
 26Bedrock offers a variety of pretrained models from Amazon (such as the Titan series), as well as models from providers like Anthropic, Meta, Cohere, and AI21 Labs.
 27
 28#### Possible investigation steps
 29
 30- Identify the user account that used high prompt token counts and whether it should perform this kind of action.
 31- Investigate large response sizes and the number of requests made by the user account.
 32- Investigate other alerts associated with the user account during the past 48 hours.
 33- Consider the time of day. If the user is a human (not a program or script), did the activity take place during a normal time of day?
 34- Examine the account's prompts and responses in the last 24 hours.
 35- If you suspect the account has been compromised, scope potentially compromised assets by tracking Amazon Bedrock model access, prompts generated, and responses to the prompts by the account in the last 24 hours.
 36
 37### False positive analysis
 38
 39- Verify the user account that used high prompt and large response sizes, has a business justification for the heavy usage of the system.
 40
 41### Response and remediation
 42
 43- Initiate the incident response process based on the outcome of the triage.
 44- Disable or limit the account during the investigation and response.
 45- Identify the possible impact of the incident and prioritize accordingly; the following actions can help you gain context:
 46    - Identify the account role in the cloud environment.
 47    - Identify if the attacker is moving laterally and compromising other Amazon Bedrock Services.
 48    - Identify any regulatory or legal ramifications related to this activity.
 49    - Identify potential resource exhaustion and impact on billing.
 50- Review the permissions assigned to the implicated user group or role behind these requests to ensure they are authorized and expected to access bedrock and ensure that the least privilege principle is being followed.
 51- Determine the initial vector abused by the attacker and take action to prevent reinfection via the same vector.
 52- Using the incident response data, update logging and audit policies to improve the mean time to detect (MTTD) and the mean time to respond (MTTR).
 53"""
 54references = [
 55    "https://atlas.mitre.org/techniques/AML.T0051",
 56    "https://owasp.org/www-project-top-10-for-large-language-model-applications/",
 57    "https://www.elastic.co/security-labs/elastic-advances-llm-security",
 58]
 59risk_score = 47
 60rule_id = "b1773d05-f349-45fb-9850-287b8f92f02d"
 61setup = """## Setup
 62
 63This rule requires that guardrails are configured in AWS Bedrock. For more information, see the AWS Bedrock documentation:
 64
 65https://docs.aws.amazon.com/bedrock/latest/userguide/guardrails-create.html
 66"""
 67severity = "medium"
 68tags = [
 69    "Domain: LLM",
 70    "Data Source: AWS Bedrock",
 71    "Data Source: Amazon Web Services",
 72    "Data Source: AWS S3",
 73    "Use Case: Potential Overload",
 74    "Use Case: Resource Exhaustion",
 75    "Mitre Atlas: LLM04",
 76    "Resources: Investigation Guide",
 77]
 78timestamp_override = "event.ingested"
 79type = "esql"
 80
 81query = '''
 82from logs-aws_bedrock.invocation-*
 83
 84// keep token usage data
 85| keep
 86  user.id,
 87  gen_ai.usage.prompt_tokens,
 88  gen_ai.usage.completion_tokens
 89
 90// Aggregate usage metrics
 91| stats
 92    Esql.ml_usage_prompt_tokens_max = max(gen_ai.usage.prompt_tokens),
 93    Esql.ml_invocations_total_count = count(*),
 94    Esql.ml_usage_completion_tokens_avg = avg(gen_ai.usage.completion_tokens)
 95  by
 96    user.id
 97
 98// Filter for suspicious usage patterns
 99| where
100  Esql.ml_usage_prompt_tokens_max > 5000
101  and Esql.ml_invocations_total_count > 10
102  and Esql.ml_usage_completion_tokens_avg > 500
103
104// Calculate a custom risk factor
105| eval Esql.ml_risk_score =
106    (Esql.ml_usage_prompt_tokens_max / 1000) *
107    Esql.ml_invocations_total_count *
108    (Esql.ml_usage_completion_tokens_avg / 500)
109
110// Filter on risk score
111| where Esql.ml_risk_score > 10
112
113// sort high risk users to top
114| sort Esql.ml_risk_score desc
115'''

Triage and analysis

Investigating Potential Abuse of Resources by High Token Count and Large Response Sizes

Amazon Bedrock is AWS’s managed service that enables developers to build and scale generative AI applications using large foundation models (FMs) from top providers.

Bedrock offers a variety of pretrained models from Amazon (such as the Titan series), as well as models from providers like Anthropic, Meta, Cohere, and AI21 Labs.

Possible investigation steps

  • Identify the user account that used high prompt token counts and whether it should perform this kind of action.
  • Investigate large response sizes and the number of requests made by the user account.
  • Investigate other alerts associated with the user account during the past 48 hours.
  • Consider the time of day. If the user is a human (not a program or script), did the activity take place during a normal time of day?
  • Examine the account's prompts and responses in the last 24 hours.
  • If you suspect the account has been compromised, scope potentially compromised assets by tracking Amazon Bedrock model access, prompts generated, and responses to the prompts by the account in the last 24 hours.

False positive analysis

  • Verify the user account that used high prompt and large response sizes, has a business justification for the heavy usage of the system.

Response and remediation

  • Initiate the incident response process based on the outcome of the triage.
  • Disable or limit the account during the investigation and response.
  • Identify the possible impact of the incident and prioritize accordingly; the following actions can help you gain context:
    • Identify the account role in the cloud environment.
    • Identify if the attacker is moving laterally and compromising other Amazon Bedrock Services.
    • Identify any regulatory or legal ramifications related to this activity.
    • Identify potential resource exhaustion and impact on billing.
  • Review the permissions assigned to the implicated user group or role behind these requests to ensure they are authorized and expected to access bedrock and ensure that the least privilege principle is being followed.
  • Determine the initial vector abused by the attacker and take action to prevent reinfection via the same vector.
  • Using the incident response data, update logging and audit policies to improve the mean time to detect (MTTD) and the mean time to respond (MTTR).

References

Related rules

to-top