本文へスキップ
Skillpedia
セキュリティ35k · #8375

securing-serverless-functions

できること

このツールは、クラウド上のコード関数(AWS Lambda、Azure Functions、Google Cloud Functionsなど)を保護するのに役立ちます。コードに必要最小限の権限だけを与え、脆弱なコンポーネントがないかを確認し、パスワードを安全に管理して、受け取るデータを検証します。

使う場面

  • ✓機密データを扱う関数をデプロイするとき。
  • ✓関数へのアクセス権限が広すぎないか確認するとき。
  • ✓ソフトウェア開発プロセスに自動的なセキュリティチェックを追加するとき。

スキルのリンク

https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/securing-serverless-functions/SKILL.md

コピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。

使い方

いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。

貼り付け用メッセージ

このスキルを使って手伝ってください:https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/securing-serverless-functions/SKILL.md このリンクのSKILL.mdファイルを読んで、私の作業でその指示に従ってください。
こういうスキルを、AIが自分で見つけてくれたら?無料のSkillpedia MCPをインストール。1行で、作業の前に15,000+のスキルから探してくれます。1分でインストール →

AIへの頼み方の例

“顧客データにアクセスするLambda関数を、どのように保護すればよいですか?”

毎週5つの新しいスキル。1分で読めます。

仕組み

各関数に最小限の権限を設定し、必要以上のリソースにアクセスできないようにします。また、コード内の古い、または危険なコンポーネントを確認し、パスワードや機密情報がコードに直接書かれず、安全に保存されているかをチェックします。

技術的な内容(元のSKILL.md)

作者による元のテキスト(英語)をGitHubからそのまま表示しています。

Securing Serverless Functions

When to Use

  • When deploying Lambda functions or Azure Functions with access to sensitive data or cloud APIs
  • When auditing existing serverless workloads for overly permissive IAM roles
  • When integrating serverless functions into a DevSecOps pipeline with automated security scanning
  • When hardcoded secrets or vulnerable dependencies are discovered in function code
  • When establishing runtime monitoring for serverless workloads to detect injection or credential theft

Do not use for container-based compute security (see securing-kubernetes-on-cloud), for API Gateway configuration (see implementing-cloud-waf-rules), or for serverless architecture design decisions.

Prerequisites

  • AWS Lambda, Azure Functions, or GCP Cloud Functions with deployment access
  • CI/CD pipeline with dependency scanning tools (npm audit, Snyk, Dependabot)
  • AWS Secrets Manager, Azure Key Vault, or HashiCorp Vault for secrets management
  • CloudWatch, Application Insights, or Cloud Logging for function monitoring

Workflow

Step 1: Enforce Least Privilege IAM Roles

Assign each Lambda function a dedicated IAM role with permissions scoped to only the specific resources it accesses. Never share IAM roles across functions.

# Create a least-privilege role for a specific Lambda function
aws iam create-role \
  --role-name order-processor-lambda-role \
  --assume-role-policy-document '{
    "Version": "2012-10-17",
    "Statement": [{
      "Effect": "Allow",
      "Principal": {"Service": "lambda.amazonaws.com"},
      "Action": "sts:AssumeRole"
    }]
  }'

# Attach a scoped policy (not AmazonDynamoDBFullAccess)
aws iam put-role-policy \
  --role-name order-processor-lambda-role \
  --policy-name order-processor-policy \
  --policy-document '{
    "Version": "2012-10-17",
    "Statement": [
      {
        "Effect": "Allow",
        "Action": ["dynamodb:PutItem", "dynamodb:GetItem"],
        "Resource": "arn:aws:dynamodb:us-east-1:123456789012:table/Orders"
      },
      {
        "Effect": "Allow",
        "Action": ["logs:CreateLogGroup", "logs:CreateLogStream", "logs:PutLogEvents"],
        "Resource": "arn:aws:logs:us-east-1:123456789012:log-group:/aws/lambda/order-processor:*"
      },
      {
        "Effect": "Allow",
        "Action": ["secretsmanager:GetSecretValue"],
        "Resource": "arn:aws:secretsmanager:us-east-1:123456789012:secret:order-api-key-*"
      }
    ]
  }'

Step 2: Eliminate Hardcoded Secrets

Replace plaintext credentials in environment variables with references to secrets management services. Use Lambda extensions or SDK calls to retrieve secrets at runtime.

# INSECURE: Hardcoded credentials in environment variable
# DB_PASSWORD = os.environ['DB_PASSWORD']  # Stored as plaintext in Lambda config

# SECURE: Retrieve from AWS Secrets Manager with caching
import boto3
from botocore.exceptions import ClientError
import json

_secret_cache = {}

def get_secret(secret_name):
    if secret_name in _secret_cache:
        return _secret_cache[secret_name]

    client = boto3.client('secretsmanager')
    response = client.get_secret_value(SecretId=secret_name)
    secret = json.loads(response['SecretString'])
    _secret_cache[secret_name] = secret
    return secret

def lambda_handler(event, context):
    db_creds = get_secret('production/database/credentials')
    db_host = db_creds['host']
    db_password = db_creds['password']
    # Use credentials securely
# Enable encryption at rest for Lambda environment variables
aws lambda update-function-configuration \
  --function-name order-processor \
  --kms-key-arn arn:aws:kms:us-east-1:123456789012:key/key-id

Step 3: Scan Dependencies for Vulnerabilities

Integrate automated dependency scanning into the CI/CD pipeline to catch vulnerable packages before deployment.

# npm audit for Node.js Lambda functions
cd lambda-function/
npm audit --audit-level=high
npm audit fix

# Snyk scanning in CI/CD pipeline
snyk test --severity-threshold=high
snyk monitor --project-name=order-processor-lambda

# pip-audit for Python Lambda functions
pip-audit -r requirements.txt --desc on --fix

# Scan Lambda deployment package with Trivy
trivy fs --severity HIGH,CRITICAL ./lambda-package/
# GitHub Actions CI/CD security scanning
name: Lambda Security Scan
on: [push, pull_request]
jobs:
  security:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

…
よくある質問

「サーバーレス関数」とは何ですか?

サーバーを自分で管理する必要なく、必要なときにクラウド上で実行される小さなコードのことです。AWS Lambda、Azure Functions、Google Cloud Functionsなどがあります。

「IAM」とは何ですか?

Identity and Access Management(ID・アクセス管理)の略で、クラウド上のどのリソースに、誰(または何)がアクセスできるかを管理する仕組みです。認可されたユーザーや関数だけが権限を持つようにします。

「依存関係の脆弱性」とは何ですか?

コードが利用するソフトウェアライブラリやコンポーネントに見つかったセキュリティ上の欠陥のことです。ライブラリが古かったり欠陥があったりすると、コードが攻撃を受ける危険があります。

詳細

作者による元の説明

Hardens serverless compute platforms (AWS Lambda, Azure Functions, Google Cloud Functions): least-privilege IAM roles, dependency vulnerability scanning, secrets management integration, input validation, function URL authentication, and runtime monitoring. Use when deploying serverless functions with sensitive access, auditing for overly permissive roles, or adding functions to a DevSecOps pipelin

repo: mukul975/Anthropic-Cybersecurity-Skills

人気

GitHubのスター
35k
ランキング
#8375
ライセンス
Apache-2.0
更新日
2026/8/31

このスキルは役に立ちますか?

0

ログイン して投票しましょう。

コメント

  • …

このリポジトリの他のスキル

似ているスキル