information-leakage-hardcoded-secrets-ai-code
БесплатноБез исполняемых скриптовНе проверенUnderstand how AI-generated code exposes sensitive information through hardcoded credentials and verbose logging. Use this skill when you need to learn about…
Об этом скилле
Sensitive Information Exposure in AI-Generated Code
The Pervasiveness of Hardcoded Secrets
A comprehensive analysis by WebProNews found:
"AI models trained on public repositories frequently suggest hardcoding API keys and credentials, as these patterns appear millions of times in their training data."
The problem is exacerbated by the fact that many developers using vibe coding are non-technical and unaware of the security implications.
1.3.1 Hardcoded Credentials
The Real-World Incident
Research from Analytics India Magazine documented a real-world incident:
"A developer used Cursor to build a SaaS app and accidentally committed hardcoded AWS credentials. Within days, attackers had discovered the exposed keys and racked up thousands of dollars in charges."
This is not theoretical—it's happening regularly.
AI-Generated Vulnerable Code
# Prompt: "Connect to AWS S3 and upload files"
import boto3
import stripe
import requests
class CloudStorage:
def __init__(self):
# ❌ CRITICAL: Hardcoded AWS credentials
self.aws_key = "AKIAIOSFODNN7EXAMPLE"
self.aws_secret = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
# ❌ CRITICAL: Hardcoded API keys
self.stripe_key = "sk_live_EXAMPLE_DO_NOT_USE_HARDCODED_KEYS"
self.sendgrid_key = "SG.EXAMPLE_KEY_DO_NOT_HARDCODE"
# ❌ CRITICAL: Database credentials in code
self.db_config = {
'host': 'prod-db.company.com',
'user': 'admin',
'password': 'SuperSecretPass123!',
'database': 'production'
}
def upload_to_s3(self, file_path, bucket_name):
# ❌ VULNERABLE: Using hardcoded credentials
s3 = boto3.client(
's3',
aws_access_key_id=self.aws_key,
aws_secret_access_key=self.aws_secret
)
s3.upload_file(file_path, bucket_name, file_path)
# Prompt: "Send API request with authentication"
def fetch_user_data(user_id):
# ❌ VULNERABLE: API key in URL
response = requests.get(
f"https://api.service.com/users/{user_id}?api_key=abc123def456"
)
return response.json()
Why This Is Critically Dangerous
1. Committed to Version Control:
- Code pushed to GitHub/GitLab
- Secrets now in git history forever
- Even if removed in later commit, still in history
- Public repos = instant compromise
- Private repos = compromised if repo breached
2. Bots Scan for Exposed Secrets:
- Automated bots scan GitHub 24/7
- Find exposed AWS keys within minutes
- Immediately start using them
- Rack up charges before you notice
3. Difficult to Rotate:
- Once exposed, must rotate all keys
- May require updating multiple services
- Downtime during rotation
- Some keys can't be rotated easily
Secure Implementation
import os
import boto3
import stripe
from dotenv import load_dotenv
from aws_secretsmanager import get_secret
import logging
# ✅ SECURE: Load environment variables from .env file (not in version control)
load_dotenv()
class CloudStorageSecure:
def __init__(self):
# ✅ SECURE: Retrieve credentials from environment variables
self.aws_key = os.getenv('AWS_ACCESS_KEY_ID')
self.aws_secret = os.getenv('AWS_SECRET_ACCESS_KEY')
# ✅ SECURE: Use AWS Secrets Manager for production
if os.getenv('ENVIRONMENT') == 'production':
secrets = self._get_secrets_from_aws()
self.stripe_key = secrets['stripe_key']
self.sendgrid_key = secrets['sendgrid_key']
else:
self.stripe_key = os.getenv('STRIPE_KEY')
self.sendgrid_key = os.getenv('SENDGRID_KEY')
# ✅ SECURE: Database connection from environment
self.db_config = {
'host': os.getenv('DB_HOST'),
'user': os.getenv('DB_USER'),
'password': os.getenv('DB_PASSWORD'),
'database': os.getenv('DB_NAME'),
'ssl_ca': os.getenv('DB_SSL_CA'), # SSL for production
'ssl_verify_cert': True
}
# ✅ SECURE: Validate all credentials are present
self._validate_configuration()
def _get_secrets_from_aws(self):
"""Retrieve secrets from AWS Secrets Manager"""
session = boto3.session.Session()
client = session.client(service_name='secretsmanager')
try:
response = client.get_secret_value(SecretId='prod/api-keys')
return json.loads(response['SecretString'])
except Exception as e:
logging.error(f"Failed to retrieve secrets: {e}")
raise
def _validate_configuration(self):
"""Ensure all required configuration is present"""
required_vars = [
'aws_key', 'aws_secret', 'stripe_key',
'sendgrid_key', 'db_config'
]
for var in required_vars:
if not getattr(self, var, None):
raise ValueError(f"Missing required configuration: {var
Установить information-leakage-hardcoded-secrets-ai-code в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл information-leakage-hardcoded-secrets-ai-code?
Understand how AI-generated code exposes sensitive information through hardcoded credentials and verbose logging. Use this skill when you need to learn about hardcoded secrets in AI code, understand logging vulnerabilities, recognize exposed API keys, or prevent information disclosure. Triggers include "hardcoded credentials", "hardcoded secrets", "API keys in code", "information leakage", "verbose logging", "exposed secrets", "AWS keys", "logging vulnerabilities", "sensitive data logs".
Как установить скилл information-leakage-hardcoded-secrets-ai-code?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл information-leakage-hardcoded-secrets-ai-code запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
от Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
от Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
от Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
от Anthropic