securing-serverless-functions

Hardens AWS Lambda, Azure Functions, and Google Cloud Functions against injection, credential theft, and supply chain attacks.

954|172|Updated Mar 13, 2026
One-click install
npx skills add https://github.com/xalgord/xalgorix --skill securing-serverless-functions
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: securing-serverless-functions
Source: https://github.com/xalgord/xalgorix/tree/main/internal/tools/skills/data/cloud-security/securing-serverless-functions
Command: npx skills add https://github.com/xalgord/xalgorix --skill securing-serverless-functions

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Serverless functions often ship with overly permissive IAM roles, hardcoded secrets, vulnerable dependencies, and unauthenticated endpoints, leaving cloud workloads exposed to injection attacks and credential theft.

Core Features & Use Cases

  • Least Privilege IAM: Create dedicated execution roles per function with policies scoped to specific DynamoDB tables, log groups, and secret ARNs.
  • Secrets & Dependency Hygiene: Migrate plaintext environment variables to AWS Secrets Manager with KMS encryption, and gate CI/CD builds on npm audit, pip-audit, Snyk, and Trivy scans.
  • Input Validation & Endpoint Security: Enforce JSON Schema validation with additionalProperties disabled, and configure Function URLs and API Gateway with IAM or Cognito authentication.
  • Use Case: Audit 47 Lambda functions and produce a report flagging SQL injection via string concatenation, shared IAM roles with s3:*, Function URLs with AuthType NONE, and dependencies with known CVEs.

Quick Start

Audit my AWS Lambda functions for overly permissive IAM roles, hardcoded secrets, unauthenticated function URLs, and vulnerable dependencies, then generate a prioritized findings report.

Frequently Asked Questions about securing-serverless-functions

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I secure AWS Lambda functions with least privilege IAM?

Create a dedicated IAM role per Lambda function and attach a scoped policy granting only the specific actions and resource ARNs it needs, such as dynamodb:PutItem on one table. Verify with aws iam simulate-principal-policy and confirm distinct role ARNs via aws lambda list-functions.

How to remove hardcoded secrets from Lambda environment variables?

Migrate plaintext credentials to AWS Secrets Manager and retrieve them at runtime with caching in a module global. Attach a KMS key via update-function-configuration, and ensure the secretsmanager:GetSecretValue resource ARN includes the random 6-character suffix or a wildcard.

Does this approach work for Azure Functions and Google Cloud Functions?

Yes, the skill covers AWS Lambda, Azure Functions, and Google Cloud Functions, using Azure Key Vault or HashiCorp Vault for secrets and Application Insights or Cloud Logging for monitoring. The same principles of least privilege, input validation, and dependency scanning apply across platforms.

Why does my Lambda secret retrieval fail with AccessDenied?

AccessDenied typically occurs when the IAM policy resource ARN omits the random 6-character suffix Secrets Manager appends to secret ARNs. Add the suffix or a wildcard to the secretsmanager:GetSecretValue resource in the execution role policy.

When should I not use this serverless hardening approach?

Do not use it for container-based compute security, which belongs to Kubernetes hardening, or for API Gateway WAF configuration, which is a separate concern. It also does not cover serverless architecture design decisions.

How do I make dependency scanning fail the CI/CD build?

Run npm audit --audit-level=high, pip-audit, or snyk test --severity-threshold=high so the command exits non-zero on high-severity findings. Avoid snyk monitor alone, since it reports vulnerabilities without gating the build.