Back to Blog
Engineering10 min read

Secret Scanner With Liveness: Distinguishing a Live AWS Key From a Revoked One

P

Pentestas Team

Security Analyst

5/10/2026
Secret Scanner With Liveness: Distinguishing a Live AWS Key From a Revoked One
TL;DR · Key insight

Discover how Pentestas differentiates between live and revoked AWS keys using our advanced secret scanner with liveness detection. Learn about the technical intricacies, the challenges faced, and the innovative solutions implemented to ensure robust security checks.

Introduction to Secret Scanning with Liveness

In the realm of cybersecurity, secret scanning has emerged as a crucial process for identifying and mitigating risks associated with exposed credentials. With cloud platforms like AWS becoming integral to modern infrastructure, the stakes are higher when it comes to securing API keys and other sensitive data. Traditional secret scanning involves searching through codebases for patterns that match known credential formats. However, this method can result in false positives, as it often fails to distinguish between active, revoked, or test keys. This is where the concept of 'liveness' becomes essential, offering a dynamic approach to identifying genuinely compromised credentials.

'Liveness' in the context of AWS keys refers to the ability to determine if a key is currently active and operational. This involves real-time verification against AWS services to confirm that a key can still perform API actions. By integrating liveness checks into secret scanning, we can significantly reduce the noise of false alerts, focusing our attention on keys that are genuinely at risk. Pentestas has been at the forefront of integrating AI-driven solutions to enhance cloud security, leveraging machine learning to discern active secrets from benign or deactivated ones.

Traditional secret scanning methods face challenges, such as the inability to scale efficiently across large codebases and differentiate between active and inactive keys. This limitation often leads to overworked security teams chasing down non-issues. To address this, our platform employs advanced algorithms that perform liveness checks, dynamically interacting with AWS to verify key status. The need for such a nuanced approach is underscored by the growing complexity of cloud environments and the increasing sophistication of cyber threats.

import boto3

aws_access_key = "your_access_key"
aws_secret_key = "your_secret_key"

client = boto3.client('sts',
                      aws_access_key_id=aws_access_key,
                      aws_secret_access_key=aws_secret_key)

try:
    response = client.get_caller_identity()
    print("Key is live: ", response)
except Exception as e:
    print("Key is not live or invalid: ", e)

Why Liveness Matters

Liveness detection is crucial as it helps prioritize incidents, reduce false positives, and focus remediation efforts on real threats, ultimately strengthening the overall security posture of cloud environments.

Understanding AWS Key Liveness

In the realm of AWS, the concept of 'liveness' for access keys is critical for maintaining secure operations. A 'live' AWS key is one that is active and has the necessary permissions to perform actions within an AWS environment. On the other hand, a 'revoked' key is either deactivated or deleted, rendering it incapable of authenticating or authorizing AWS API calls. This distinction is crucial for both maintaining security and ensuring that your applications function without interruption. At Pentestas, we focus on identifying these states accurately to prevent unauthorized access and maintain operational integrity.

There are several common scenarios that lead to the revocation of AWS keys. For instance, a key might be revoked if it has been compromised, if an employee leaves the organization, or if there's a change in policy that no longer requires the key. The risks involved with not revoking a key promptly can be severe, ranging from unauthorized access to data breaches. This is why AWS best practices strongly advocate for regular key rotation and immediate revocation of keys that are no longer in use or necessary for active processes.

Distinguishing between live and inactive keys presents a set of technical challenges. One primary challenge is the lack of immediate feedback from AWS when a key is deactivated. To address this, we can perform a simple API call to check the status of a key. This call can be made using the AWS CLI:

aws iam list-access-keys --user-name <username> --query 'AccessKeyMetadata[?Status==`Active`]' --output json

This command helps identify active keys for a given user, allowing us to determine if a key remains live. However, integrating this check into an automated workflow requires careful orchestration to avoid false positives and ensure timely alerts for potential security issues.

STS and Live Calls: Ensuring Accurate Detection

The AWS Security Token Service (STS) is crucial in verifying the validity of keys. By generating temporary credentials, STS allows us to make live API calls that test whether a key is still active. These credentials are not only short-lived but also limited in scope, reducing security risks during the verification process. When we use STS to assume roles or generate tokens, we can quickly determine the status of an AWS key. This method provides a reliable way to confirm whether a key is live or revoked, bolstering our secret scanning capabilities.

Implementing live calls to AWS APIs is a straightforward yet potent technique for checking key liveness. By leveraging AWS SDKs, we can programmatically interact with various services to verify if an access key is still valid. A typical approach involves calling the GetCallerIdentity API, which essentially verifies if the credentials are capable of making requests. If the call is successful, the key is active; otherwise, it's likely revoked or invalid.

import boto3

client = boto3.client('sts')

try:
    response = client.get_caller_identity()
    print("Key is active: ", response)
except client.exceptions.ClientError as e:
    print("Key is revoked or invalid.", e)

Balancing accuracy with performance is a critical aspect of our live detection processes. While frequent live calls can assure us of up-to-date key statuses, they can also strain resources and incur additional costs. Therefore, it's essential to optimize these checks by scheduling them efficiently and leveraging caching mechanisms. By doing so, we ensure that our secret scanner remains both accurate and efficient, providing reliable results without unnecessary overhead.

Rate-Limit Budgeting in Live Detection

When we're conducting live detection of AWS keys, one of the primary hurdles we encounter is dealing with API rate limits. AWS imposes a strict limit on the number of API calls that can be made in a given time frame. This limitation is critical because exceeding these limits can result in temporary blacklisting, delaying the detection process. Our goal is to ensure that each API call is used judiciously to maximize our scanning efficiency without incurring penalties.

To address these challenges, we implement a rate-limit budgeting strategy that involves calculating the number of API calls required per key and allocating them accordingly. This means understanding the priorities and scheduling API calls to ensure that critical checks are never missed. Maintaining a dynamic budget that adapts to real-time conditions is crucial. For example, we may check the validity of a key less frequently if it's not actively being used, thus conserving our API call allotment.

import boto3
from time import sleep

client = boto3.client('sts')
rate_limit = 1000  # hypothetical API call limit
call_interval = 60 / rate_limit  # time between calls

for key in aws_keys:
    try:
        response = client.get_caller_identity()
        print(f"Key {key} is live.")
    except Exception as e:
        print(f"Failed to verify key {key}: {e}")
    sleep(call_interval)

The impact of rate limiting on our secret scanning process is significant. While we aim for real-time detection, rate limits can slow down our ability to promptly identify whether a key is active or revoked. This constraint pushes us to continuously optimize our methods, ensuring that our scanning process remains effective while adhering to these limitations. By leveraging intelligent backoff algorithms and prioritizing high-risk keys, we can mitigate the negative effects of rate limits and maintain robust live detection capabilities.

Audit-Trail Tradeoffs

Maintaining detailed audit trails is crucial for compliance, particularly in environments governed by regulations like GDPR and PCI-DSS. These logs provide an immutable record of who accessed what and when, ensuring that any access to sensitive information is traceable. However, the challenge lies in balancing the depth of logging with system performance. Excessive logging can lead to increased storage costs and can degrade system speed due to the overhead involved in capturing every single event.

At Pentestas, we address these challenges by implementing a sparse logging mechanism that captures essential data while maintaining performance. We selectively log key events such as credential access and configuration changes, using tags to classify the importance of each log entry. This allows us to prioritize critical information without overwhelming our storage systems or impacting service responsiveness.

logger = logging.getLogger('audit')
logger.setLevel(logging.INFO)

# Example of logging a critical event
def log_credential_access(user_id, key_id):
    logger.info(f"User {user_id} accessed AWS key {key_id}")

While comprehensive logging is non-negotiable, we also employ log rotation and archiving strategies to manage data volume effectively. Logs older than 30 days are archived and compressed, reducing their footprint and ensuring that our systems remain agile. By doing this, we not only maintain compliance but also optimize our resources, ensuring that performance is not sacrificed for the sake of transparency.

Integration with Platforms: GitHub and Slack

Integrating our secret scanning capabilities with platforms like GitHub and Slack has been a game-changer for organizations aiming to enhance their security posture. By embedding our scanners directly into these platforms, we enable continuous monitoring of repositories and communication channels. This integration ensures that any potential exposure of sensitive data, such as AWS keys, is immediately detected and flagged. For instance, when a developer pushes code to a GitHub repository, our scanner analyzes the changes in real-time, identifying secrets before they can be exploited.

The benefits of such integration extend beyond mere detection; they encompass real-time alerts and automated responses. By sending notifications directly to Slack channels, we allow teams to react promptly to any security incidents. This immediate feedback loop is crucial for mitigating risks associated with leaked secrets. Our system can be configured to automatically create incident tickets or trigger workflow automation, ensuring that the right people are alerted without delay.

const slackWebhookUrl = process.env.SLACK_WEBHOOK_URL;
const payload = {
  text: "Secret detected in repository! Please review immediately.",
  attachments: [
    {
      title: "Repository Link",
      title_link: "https://github.com/org/repo",
      text: "A sensitive key was found in commit abc123."
    }
  ]
};

fetch(slackWebhookUrl, {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json'
  },
  body: JSON.stringify(payload)
});

Our integration use cases highlight the operational advantages of this approach. For instance, when a secret is detected in a GitHub repository, an automated alert is sent via Slack, providing a direct link to the affected commit. This seamless integration not only accelerates incident response but also promotes a culture of security awareness among development teams. By leveraging these platforms, we empower organizations to maintain a proactive security stance, reducing the risk of data breaches caused by exposed secrets.

Engineering Insights and Implementation Details

Our secret scanner is built on a robust architecture that focuses on real-time detection and validation of AWS keys. At its core, the scanner leverages a multi-threaded approach to efficiently process large volumes of data streams. The technical implementation involves parsing configuration files and repositories for patterns resembling AWS keys. Once identified, the keys are subjected to a liveness check, which involves a series of API calls to AWS services to confirm their active status. This ensures that the keys we flag are not only valid but currently active, thus reducing false positives significantly.

Incorporating AI into our secret scanning process has proven invaluable for enhancing detection accuracy and speed. Machine learning models are trained on vast datasets to recognize patterns and anomalies indicative of secret keys. By continuously updating these models with new data, we finetune our detection algorithms to adapt to emerging threats. This AI-driven approach also helps prioritize scanning tasks based on the likelihood of finding active secrets, allowing us to allocate resources more effectively. The integration of AI not only accelerates the scanning process but also improves precision, catching even the most subtly hidden keys.

Key Challenges and Solutions

During the development, we faced challenges such as differentiating between revoked and active keys. Implementing a reliable liveness check was crucial, as AWS rate limiting posed another hurdle. We addressed this by optimizing API call schedules and caching results to minimize redundant requests.

One of the major challenges was distinguishing revoked keys from those still live. Our solution involved a hybrid approach utilizing both static analysis and dynamic validation. By maintaining a cache of known revoked keys and periodically refreshing it with data from AWS, we minimized unnecessary API calls. Additionally, handling AWS's rate limits required careful scheduling and batching of requests. We implemented a queue system that prioritizes urgent checks while staggering non-critical ones, ensuring efficient resource use without overwhelming AWS's API limits.

Limitations and Future Directions

While our secret scanning with liveness detection provides significant advantages, it is not without its limitations. Currently, the system relies heavily on pattern matching to identify AWS keys, which can lead to false positives. For instance, non-secret strings matching the pattern of an AWS key can trigger alerts. Additionally, the liveness check mechanism requires network access to AWS services to verify the status of keys. This dependency can introduce latency, especially in environments with restricted internet access or stringent firewall rules.

aws_access_key_id = "AKIA..."
aws_secret_access_key = "wJalr..."

# Liveness check example
import boto3

def check_key_validity(aws_access_key_id, aws_secret_access_key):
    client = boto3.client(
        'iam',
        aws_access_key_id=aws_access_key_id,
        aws_secret_access_key=aws_secret_access_key
    )
    try:
        client.get_user()
        return "Key is live"
    except client.exceptions.ClientError:
        return "Key is revoked"

print(check_key_validity("AKIA...", "wJalr..."))

Looking ahead, we are exploring several enhancements to improve both detection and response. One promising direction is the integration of machine learning algorithms to better differentiate between actual secrets and benign data. These models could learn from historical data to reduce false positives and improve detection accuracy. Another potential improvement is the automation of key rotation processes. By integrating with AWS Lambda functions, we could automatically rotate keys upon detection, minimizing the risk of exposure.

Exploring New Technologies

We're investigating the use of blockchain technology for immutable logging of key usage and revocation events, potentially enhancing traceability and accountability in secret management systems.

Finally, we are actively exploring new technologies and approaches in the secret scanning domain. Technologies such as blockchain could offer innovative ways to manage and audit key usage, ensuring an immutable record of all access events. Additionally, the development of cross-platform scanning tools that can operate seamlessly across different cloud environments will be crucial. As the landscape of cloud services evolves, so too must our approaches to security, ensuring that our systems remain robust against emerging threats.

Try it on your stack

Free tier includes 10 scans/month on a verified domain. No credit card required.

Start scanning

How Pentestas runs this in production

Everything above is shipped as part of Pentestas — a pentesting-as-a-service platform built around an AI penetration testing system that orchestrates dozens of deterministic detectors alongside an LLM-driven planner and reflector. Our penetration testing with Claude pipeline handles the audit-trail-grade reasoning (causal chains, evidence weighting, narrative attack paths) while our penetration testing with DeepSeek pipeline handles high-volume parallel coverage at the kind of unit cost that lets us re-run a full B2B SaaS pentest weekly without burning the customer's annual budget on a single engagement.

If you're evaluating a vendor for penetration testing with AI, the questions worth pressing on are exactly the ones this post walks through — accuracy gating, replay verification, payload safety, evidence chains, retest cadence. Those are what separate a real pipeline from a wrapper around a public LLM.

Alexander Sverdlov

Alexander Sverdlov

Founder of Pentestas. Author of 2 information security books, cybersecurity speaker at the largest cybersecurity conferences in Asia and a United Nations conference panelist. Former Microsoft security consulting team member, external cybersecurity consultant at the Emirates Nuclear Energy Corporation.