sast-graphql
Detect GraphQL-specific vulnerabilities including injection, introspection exposure, query depth attacks, and authorization bypasses. Use when reviewing any GraphQL API implementation or when the app consumes a GraphQL endpoint.
- License 许可
- Apache-2.0
- 最近更新
- 2026-10-05
- Stars
- ★ 1
- Forks
- 0
01 前言 Front Matter
- name
- sast-graphql
- description
- Detect GraphQL-specific vulnerabilities including injection, introspection exposure, query depth attacks, and authorization bypasses. Use when reviewing any GraphQL API implementation or when the app consumes a GraphQL endpoint.
03 SKILL.md 正文
SAST: GraphQL Security Detection
Scan for GraphQL-specific vulnerabilities — OWASP API Security Top 10.
What to Look For
High Risk Patterns
// ❌ VULNERABLE: introspection enabled in production
const server = new ApolloServer({
schema,
introspection: true, // exposes full schema to attackers
});
// ❌ VULNERABLE: no query depth limit
// Attacker can send: { user { friends { friends { friends { ... } } } } }
// ❌ VULNERABLE: no query cost/complexity limit
// Attacker can request massive data in a single query
// ❌ VULNERABLE: field-level injection
const query = `
query { user(id: "${userId}") { ... } } // injection in inline argument
`;
// ❌ VULNERABLE: batch query abuse
// GraphQL allows multiple operations — no rate limiting per-operation
// ❌ VULNERABLE: no authorization at resolver level
const resolvers = {
Query: {
users: () => User.findAll(), // no auth check in resolver!
}
};
Safe Patterns
// ✅ SAFE: disable introspection in production
const server = new ApolloServer({
schema,
introspection: process.env.NODE_ENV !== 'production',
});
// ✅ SAFE: depth limiting
import depthLimit from 'graphql-depth-limit';
const server = new ApolloServer({
validationRules: [depthLimit(5)],
});
// ✅ SAFE: resolver-level auth
const resolvers = {
Query: {
users: (_, __, context) => {
if (!context.user) throw new AuthenticationError('Not authenticated');
if (context.user.role !== 'admin') throw new ForbiddenError('Not authorized');
return User.findAll();
}
}
};
// ✅ SAFE: use variables (not inline string interpolation)
const query = `query GetUser($id: ID!) { user(id: $id) { ... } }`;
client.query({ query, variables: { id: userId } });
Scan Checklist
- [ ] Introspection disabled in production (
NODE_ENV === 'production') - [ ] Query depth limit configured (max 5-7 levels)
- [ ] Query complexity/cost limit configured
- [ ] All resolvers check authentication context
- [ ] Rate limiting per query operation
- [ ] Variables used instead of string interpolation in dynamic queries
- [ ] Subscription endpoints protected with auth
Severity Matrix
| Pattern | Severity |
|---|---|
| Introspection in production | High |
| No depth limit (DoS) | High |
| Resolver without auth check | Critical |
| GraphQL injection via inline args | High |
| Batch query abuse (no rate limit) | Medium |
Remediation
- Disable introspection in production environments
- Install
graphql-depth-limitand set max to 5 - Add authentication middleware that populates
context.user - Check
context.userin every resolver that returns sensitive data - Use persisted queries in production to prevent arbitrary query execution
04 同仓库更多 Skills
skill-creator
To create new CLI skills following Anthropic's official best practices with zero manual configuration. This skill automates brainstorming, template application, validation, and installation processes while maintaining progressive disclosure patterns and writing style standards.
business-investment-advisor
Business investment analysis and capital allocation advisor. Use when evaluating whether to invest in equipment, real estate, a new business, hiring, technology, or any capital expenditure. Also use for ROI calculations, IRR, NPV, payback period, build vs buy decisions, lease vs buy analysis, vendor evaluation, or deciding where to allocate limited budget for maximum return.
add-new-agent
خطوات تفصيليّة لإضافة وكيل ذكاء اصطناعي جديد إلى منصّة Kalmeron من الفكرة إلى الإنتاج
writing-skills
Use when creating new skills, editing existing skills, or verifying skills work before deployment
writing-plans
Use when you have a spec or requirements for a multi-step task, before touching code
web-design-guidelines
Review UI code for Web Interface Guidelines compliance. Use when asked to "review my UI", "check accessibility", "audit design", "review UX", or "check my site against best practices".