api-security-best-practices

Implement security patterns for REST, GraphQL, and WebSocket APIs.

Updated Jun 5, 2026
One-click install
npx skills add https://github.com/0xRayAI/xray --skill api-security-best-practices-0xrayai
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: api-security-best-practices
Source: https://github.com/0xRayAI/xray/tree/main/integrations/api-security-best-practices
Command: npx skills add https://github.com/0xRayAI/xray --skill api-security-best-practices-0xrayai

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires jsonwebtoken, bcrypt, express-rate-limit, rate-limit-redis, ioredis, zod, isomorphic-dompurify, helmet.

What problem does it solve?

This skill addresses the critical need for robust API security by providing a comprehensive framework to identify, mitigate, and prevent common vulnerabilities like injection, broken authentication, and DDoS attacks.

Core Features & Use Cases

  • Security Pattern Implementation: Provides actionable guidance for JWT authentication, role-based access control (RBAC), and parameterized queries to prevent SQL injection.
  • Automated Protection Strategies: Offers ready-to-use configurations for rate limiting, input validation using Zod, and security header management via Helmet.js.
  • Use Case: Use this skill when conducting a security review of your REST or GraphQL endpoints to ensure compliance with the OWASP API Security Top 10 and to harden your production environment against unauthorized access.

Quick Start

Use the api-security-best-practices skill to audit the current authentication middleware and suggest improvements for preventing SQL injection in the user profile endpoints.

Frequently Asked Questions about api-security-best-practices

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

FAQPage Schema
How do I secure REST and GraphQL APIs against the OWASP API Security Top 10?

Securing APIs against the OWASP API Security Top 10 requires implementing JWT authentication, input validation, and rate limiting. This skill provides comprehensive security patterns to mitigate common vulnerabilities like injection and broken authentication across REST, GraphQL, and WebSocket endpoints.

What is the best way to prevent SQL injection and sanitize API inputs?

Preventing SQL injection requires parameterized queries and strict input sanitization. This skill uses Zod for schema validation and isomorphic-dompurify to sanitize inputs, ensuring malicious payloads are neutralized before reaching your backend database or GraphQL resolvers.

How do I configure rate limiting for an Express API using Redis?

Configuring rate limiting for Express APIs involves applying middleware to restrict excessive requests. This skill utilizes express-rate-limit and rate-limit-redis with ioredis to establish automated protection strategies, preventing DDoS attacks and API abuse in production environments.

How does JWT authentication and role-based access control work for API protection?

JWT authentication and role-based access control (RBAC) work by verifying user tokens and restricting endpoint permissions based on user roles. This skill implements these security patterns using jsonwebtoken and bcrypt to harden your API against unauthorized access.

Can I use Helmet.js to manage security headers for my Node.js API?

Helmet.js can be used to manage HTTP security headers for your Node.js API. This skill offers ready-to-use configurations for security header management via Helmet.js, helping protect your application from cross-site scripting and other web vulnerabilities.

Does this skill provide security patterns for WebSocket APIs?

This skill provides comprehensive security patterns for WebSocket APIs in addition to REST and GraphQL. It covers the full lifecycle of API protection including authentication, input sanitization, and data encryption specifically tailored for WebSocket connections.