Token导航 LogoToken导航TokenDH.com
研究检索external-servicegithub未标认证来源可访问许可证需确认审计提醒

security-testing安全测试

Agent Skill

用于辅助安全审计、权限检查、凭据风险、认证流程和常见漏洞排查。它适合让 Agent 梳理敏感配置、检查依赖风险、分析鉴权逻辑或生成安全复核清单。使用时不能把工具输出直接当最终结论,涉及密钥、令牌、用户数据或生产系统时,应先确认最小权限、脱敏方式和操作边界。

总安装

321

周安装

13

GitHub Stars

4

下载量

101
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:security-testing(安全测试)
来源仓库:https://github.com/petrkindlmann/qa-skills
仓库路径:skills/security-testing
安装命令:
npx skills add https://github.com/petrkindlmann/qa-skills --skill security-testing
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/petrkindlmann/qa-skills --skill security-testing

简介

用于辅助安全审计、权限检查和常见漏洞排查,适合生成安全复核清单。

  • 可帮助梳理敏感配置、分析鉴权逻辑并识别依赖风险。
  • 通过 GitHub 安装,支持 Codex、Claude、Cursor、Gemini CLI 等宿主环境。
  • 不能将工具输出直接当作最终结论;涉及密钥或生产系统时应先确认最小权限与脱敏方式。
  • security-testing 属于研究检索类 Skill,可作为该场景下的辅助能力补充。

SKILL.md

Before starting: Check for .agents/qa-project-context.md in the project root. It contains auth mechanisms, compliance requirements, and infrastructure details that determine which security checks apply.


Discovery Questions

  1. Threat model: Has the team identified key assets, threat actors, and attack surfaces? If not, start with a lightweight threat model before writing security tests.
  2. Auth mechanism: Session cookies, JWT, OAuth 2.0/OIDC, API keys, or multi-factor? Each has distinct test patterns.
  3. Compliance requirements: SOC 2, HIPAA, PCI DSS, GDPR? These mandate specific security controls that must be validated.
  4. Existing security tooling: Already running Snyk, Dependabot, SonarQube, or ZAP? Check CI config for existing security stages.
  5. API surface: REST, GraphQL, gRPC? Each protocol has specific injection and authorization vulnerabilities.
  6. Deployment model: Cloud (AWS/GCP/Azure), containers, serverless? Infrastructure misconfigurations are OWASP #5.

Core Principles

  1. Security is a mindset, not a phase. Security testing is continuous. It runs in CI on every PR, not as a quarterly penetration test.
  2. OWASP Top 10 is the minimum. It covers the most common and impactful vulnerability classes. It is not exhaustive -- domain-specific threats (healthcare data, financial transactions) require additional analysis.
  3. Shift-left security. Catch vulnerabilities at the earliest possible stage: SAST in the IDE, dependency scanning on commit, DAST in staging, penetration testing before release.
  4. Defense in depth. No single tool catches everything. Layer SAST + dependency scanning + DAST + auth testing + secret scanning for comprehensive coverage.
  5. Continuous dependency scanning. 80%+ of application code is third-party. Known vulnerabilities in dependencies are the lowest-effort attack vector. Scan on every build.

OWASP Top 10 (2021) Testing Checklist

A01: Broken Access Control

The #1 vulnerability. Users can act outside their intended permissions.

What to test:

  • Insecure Direct Object References (IDOR): change resource IDs in URLs/API calls to access other users' data
  • Missing function-level access control: access admin endpoints as a regular user
  • Path traversal: ../../etc/passwd in file parameters
  • CORS misconfiguration: can a malicious origin make authenticated requests?
// IDOR test: user A should not access user B's order
test('should reject access to another user\'s order', async ({ request }) => {
  const response = await request.get('/api/orders/order-belonging-to-user-b', {
    headers: { Authorization: `Bearer ${userAToken}` },
  });
  expect(response.status()).toBe(403);
});

// Vertical privilege escalation: regular user hits admin endpoint
test('should reject non-admin from admin endpoints', async ({ request }) => {
  const response = await request.delete('/api/admin/users/some-user-id', {
    headers: { Authorization: `Bearer ${regularUserToken}` },
  });
  expect(response.status()).toBe(403);
});

// CORS: verify only allowed origins
test('should reject cross-origin requests from untrusted origins', async ({ request }) => {
  const response = await request.get('/api/user/profile', {
    headers: {
      Origin: 'https://evil-site.example.com',
      Authorization: `Bearer ${validToken}`,
    },
  });
  const corsHeader = response.headers()['access-control-allow-origin'];
  expect(corsHeader).not.toBe('*');
  expect(corsHeader).not.toBe('https://evil-site.example.com');
});

A02: Cryptographic Failures

Sensitive data exposed due to weak or missing encryption.

What to test:

  • Data in transit: TLS version, cipher suites, HSTS header
  • Data at rest: passwords hashed with bcrypt/argon2 (not MD5/SHA1)
  • Sensitive data in URLs, logs, or error messages
  • Cookies missing Secure, HttpOnly, SameSite flags
test('should set secure cookie flags on session', async ({ request }) => {
  const response = await request.post('/api/auth/login', {
    data: { email: 'test@example.com', password: 'validPassword1!' },
  });
  const setCookie = response.headers()['set-cookie'] ?? '';
  expect(setCookie).toContain('Secure');
  expect(setCookie).toContain('HttpOnly');
  expect(setCookie).toMatch(/SameSite=(Strict|Lax)/);
});

test('should include security headers', async ({ request }) => {
  const response = await request.get('/');
  expect(response.headers()['strict-transport-security']).toBeDefined();
  expect(response.headers()['x-content-type-options']).toBe('nosniff');
  expect(response.headers()['x-frame-options']).toMatch(/DENY|SAMEORIGIN/);
});

A03: Injection

Untrusted data sent to an interpreter as part of a command or query.

What to test:

  • SQL injection in query parameters, form fields, headers
  • XSS (reflected, stored, DOM-based) in user-generated content
  • CSRF on state-changing operations
  • Command injection in file names, search queries, webhook URLs
// SQL injection patterns
const sqlPayloads = [
  "' OR '1'='1",
  "'; DROP TABLE users; --",
  "1 UNION SELECT null, username, password FROM users --",
  "admin'--",
];

for (const payload of sqlPayloads) {
  test(`should reject SQL injection: ${payload.slice(0, 30)}`, async ({ request }) => {
    const response = await request.get(`/api/search?q=${encodeURIComponent(payload)}`);
    expect(response.status()).not.toBe(500); // Server error = likely vulnerable
    const body = await response.text();
    expect(body).not.toContain('SQL');
    expect(body).not.toContain('syntax error');
    expect(body).not.toContain('mysql');
  });
}

// XSS via stored user input
test('should sanitize stored XSS in user profile', async ({ page }) => {
  const xssPayload = '<img src=x onerror=alert(document.cookie)>';
  // Store malicious input via API
  await page.request.put('/api/profile', {
    data: { displayName: xssPayload },
    headers: { Authorization: `Bearer ${token}` },
  });
  // Load page that renders the profile
  await page.goto('/profile');
  // Verify the script did not execute (no alert dialog)
  // and the content is either escaped or stripped
  const nameElement = page.getByTestId('display-name');
  const nameText = await nameElement.innerHTML();
  expect(nameText).not.toContain('<img');
  expect(nameText).not.toContain('onerror');
});

// CSRF: state-changing requests require valid token
test('should reject POST without CSRF token', async ({ request }) => {
  const response = await request.post('/api/account/change-email', {
    data: { email: 'attacker@example.com' },
    headers: { Cookie: `session=${validSessionCookie}` },
    // Deliberately omitting CSRF token
  });
  expect(response.status()).toBe(403);
});

A04: Insecure Design

Flawed architecture that cannot be fixed by implementation alone.

What to test: Rate limiting on auth endpoints (fire 15 concurrent login attempts, expect 429), business logic abuse (negative quantities, coupon stacking), missing account lockout after failed attempts.

A05: Security Misconfiguration

Default credentials, unnecessary features enabled, overly verbose errors.

What to test:

  • Debug/stack traces disabled in production
  • Default credentials changed
  • Unnecessary HTTP methods disabled
  • Directory listing disabled
  • Admin panels not publicly accessible
test('should not expose stack traces in production errors', async ({ request }) => {
  const response = await request.get('/api/nonexistent-endpoint');
  const body = await response.text();
  expect(body).not.toContain('at Object.');
  expect(body).not.toContain('node_modules');
  expect(body).not.toMatch(/\.ts:\d+:\d+/);
  expect(body).not.toMatch(/\.js:\d+:\d+/);
});

test('should disable TRACE method', async ({ request }) => {
  const response = await request.fetch('/api/health', { method: 'TRACE' });
  expect(response.status()).toBe(405);
});

A06: Vulnerable and Outdated Components

Known vulnerabilities in third-party dependencies.

Automated scanning (see CI Integration section below).

A07: Identification and Authentication Failures

Broken authentication, weak passwords, credential stuffing.

See Auth Testing Patterns section below.

A08: Software and Data Integrity Failures

Unsigned updates, insecure deserialization, untrusted CI/CD pipelines.

What to test:

  • Subresource Integrity (SRI) on CDN scripts
  • Content Security Policy headers
test('should include Content-Security-Policy', async ({ request }) => {
  const response = await request.get('/');
  const csp = response.headers()['content-security-policy'];
  expect(csp).toBeDefined();
  expect(csp).not.toContain("'unsafe-inline'");
  expect(csp).not.toContain("'unsafe-eval'");
});

A09: Security Logging and Monitoring Failures

Insufficient logging of security events.

What to test:

  • Failed login attempts are logged
  • Admin actions are audit-logged
  • Logs do not contain sensitive data (passwords, tokens, PII)

A10: Server-Side Request Forgery (SSRF)

Server makes requests to attacker-controlled URLs.

// SSRF: prevent internal network access via user-supplied URLs
const ssrfPayloads = [
  'http://169.254.169.254/latest/meta-data/',  // AWS metadata
  'http://localhost:6379/',                      // Redis
  'http://127.0.0.1:3000/api/admin',            // Loopback
  'file:///etc/passwd',                          // Local file
];

for (const payload of ssrfPayloads) {
  test(`should block SSRF attempt: ${new URL(payload).hostname}`, async ({ request }) => {
    const response = await request.post('/api/webhook/test', {
      data: { callbackUrl: payload },
      headers: { Authorization: `Bearer ${token}` },
    });
    expect(response.status()).toBeOneOf([400, 403, 422]);
  });
}

Automated Security Scanning

OWASP ZAP

# GitHub Actions: ZAP baseline scan against staging
security-scan:
  runs-on: ubuntu-latest
  steps:
    - name: ZAP Baseline Scan
      uses: zaproxy/action-baseline@v0.14.0
      with:
        target: 'https://staging.example.com'
        rules_file_name: '.zap/rules.tsv'
        cmd_options: '-a'
    - name: Upload ZAP Report
      if: always()
      uses: actions/upload-artifact@v4
      with:
        name: zap-report
        path: report_html.html

For API scanning, use zap-api-scan.py with your OpenAPI spec. For full scans, use zap-full-scan.py via Docker (ghcr.io/zaproxy/zaproxy:stable).

Dependency Scanning

# GitHub Actions: npm audit + Snyk
dependency-check:
  runs-on: ubuntu-latest
  steps:
    - uses: actions/checkout@v4
    - run: npm ci
    - name: npm audit
      run: npm audit --audit-level=high
      continue-on-error: true

    - name: Snyk test
      uses: snyk/actions/node@master
      env:
        SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
      with:
        args: --severity-threshold=high

Configure Dependabot in .github/dependabot.yml with daily npm updates and security team reviewers.

SAST (Static Analysis)

// .eslintrc.js -- security-focused plugins
module.exports = {
  plugins: ['security', 'no-unsanitized'],
  extends: ['plugin:security/recommended-legacy'],
  rules: {
    'security/detect-object-injection': 'warn',
    'security/detect-non-literal-regexp': 'warn',
    'security/detect-unsafe-regex': 'error',
    'security/detect-eval-with-expression': 'error',
    'no-unsanitized/method': 'error',
    'no-unsanitized/property': 'error',
  },
};

For deeper multi-language SAST, use Semgrep (semgrep/semgrep-action@v1) with rulesets p/owasp-top-ten, p/javascript, p/typescript.

Secret Scanning

Use TruffleHog (trufflesecurity/trufflehog@main) in CI with --only-verified and full git history (fetch-depth: 0). For pre-commit prevention, use git-secrets with git secrets --install && git secrets --register-aws.


Auth Testing Patterns

Session Management

test('should invalidate session on logout', async ({ request, context }) => {
  // Login and get session
  const loginResponse = await request.post('/api/auth/login', {
    data: { email: 'test@example.com', password: 'validPassword1!' },
  });
  const sessionCookie = loginResponse.headers()['set-cookie'];

  // Logout
  await request.post('/api/auth/logout');

  // Attempt to use old session
  const response = await request.get('/api/user/profile', {
    headers: { Cookie: sessionCookie },
  });
  expect(response.status()).toBe(401);
});

JWT Testing

import * as jose from 'jose';

test('should reject expired JWT', async ({ request }) => {
  const expiredToken = await new jose.SignJWT({ sub: 'user-1' })
    .setProtectedHeader({ alg: 'HS256' })
    .setExpirationTime('-1h') // Expired 1 hour ago
    .sign(new TextEncoder().encode('test-secret'));

  const response = await request.get('/api/user/profile', {
    headers: { Authorization: `Bearer ${expiredToken}` },
  });
  expect(response.status()).toBe(401);
});

test('should reject JWT with "none" algorithm', async ({ request }) => {
  // Algorithm confusion attack: forged token with alg: none
  const header = Buffer.from(JSON.stringify({ alg: 'none', typ: 'JWT' })).toString('base64url');
  const payload = Buffer.from(JSON.stringify({ sub: 'admin', role: 'admin' })).toString('base64url');
  const noneToken = `${header}.${payload}.`;

  const response = await request.get('/api/admin/dashboard', {
    headers: { Authorization: `Bearer ${noneToken}` },
  });
  expect(response.status()).toBe(401);
});

RBAC Testing

const endpoints = [
  { method: 'GET', path: '/api/admin/users', allowedRoles: ['admin'] },
  { method: 'DELETE', path: '/api/admin/users/u-1', allowedRoles: ['admin'] },
  { method: 'GET', path: '/api/reports', allowedRoles: ['admin', 'manager'] },
  { method: 'GET', path: '/api/profile', allowedRoles: ['admin', 'manager', 'user'] },
];

for (const endpoint of endpoints) {
  for (const role of ['admin', 'manager', 'user', 'guest']) {
    const shouldAllow = endpoint.allowedRoles.includes(role);
    test(`${role} ${shouldAllow ? 'can' : 'cannot'} ${endpoint.method} ${endpoint.path}`, async ({ request }) => {
      const token = await getTokenForRole(role);
      const response = await request.fetch(endpoint.path, {
        method: endpoint.method,
        headers: token ? { Authorization: `Bearer ${token}` } : {},
      });
      if (shouldAllow) {
        expect(response.status()).not.toBeOneOf([401, 403]);
      } else {
        expect(response.status()).toBeOneOf([401, 403]);
      }
    });
  }
}

Also test: session rotation after login (prevent session fixation), JWT signed with wrong key, and OAuth state parameter tampering.


CI Integration

A complete security pipeline has five layers, each as a CI step:

  1. Secret scanning -- TruffleHog with --only-verified
  2. Dependency check -- npm audit --audit-level=high
  3. SAST -- ESLint security plugins against source
  4. DAST -- ZAP baseline scan against staging URL
  5. Custom auth tests -- npx playwright test --project=security

Security as PR Gate

Block merges when npm audit --json reports high/critical vulnerabilities. Parse the JSON output and fail the step with exit 1 if count > 0.


Anti-Patterns

Security testing only before release. Vulnerabilities found late are expensive to fix. Run security scans on every PR, not quarterly.

Relying on a single tool. ZAP misses auth logic bugs. Snyk misses custom code vulnerabilities. ESLint misses runtime issues. Layer multiple tools for defense in depth.

Ignoring npm audit warnings. "We'll fix it later" becomes a backlog of known vulnerabilities. Treat high/critical dependency vulnerabilities as build failures.

Testing only happy-path auth. Login works -- great. Does logout actually invalidate the session? Can an expired token still access resources? Does role escalation work?

Hardcoding secrets in test files. Security tests that contain real API keys or passwords are themselves a vulnerability. Use environment variables and CI secrets.

Skipping SSRF testing. Any feature that accepts a URL (webhooks, image uploads, imports) is an SSRF vector. Test with internal network addresses.

Testing only known payloads. The XSS and SQLi payloads above are examples, not an exhaustive list. Use tools like ZAP that maintain current payload databases.


Done When

  • OWASP Top 10 checklist reviewed against the application and each item marked as tested, mitigated, or accepted risk with justification.
  • ZAP passive scan run against the staging environment with all findings triaged (critical/high addressed, medium/low tracked in backlog).
  • Dependency scanning enabled on the repository via Snyk or Dependabot, with high/critical vulnerabilities treated as build failures.
  • SAST lint rules (ESLint security plugin or Semgrep) enabled in CI and producing zero unresolved errors on the main branch.
  • Auth and session edge cases explicitly tested: CSRF protection, token expiry rejection, session invalidation on logout, and role escalation prevention.

Related Skills

  • ci-cd-integration -- Pipeline stages for security scanning, gating deployments on security results.
  • compliance-testing -- Mapping security tests to regulatory requirements (SOC 2, HIPAA, PCI).
  • api-testing -- API-specific security patterns: auth header validation, input sanitization, rate limiting.
  • test-environments -- Secure test environment configuration, secret management, network isolation.
  • database-testing -- Data integrity validation, access control at the database level.

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

34.37%
按下载量换算35

Claude

30.96%
按下载量换算31

Cursor

17.96%
按下载量换算18

Gemini CLI

9.75%
按下载量换算10

安全审计

Gen Agent Trust Hub

通过

Socket

可疑

Snyk

可疑

权限和风险

external-service

该 Skill 可能调用第三方服务、云服务或外部模型 API,使用前需要确认账号、额度、数据发送范围和服务条款。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在 warning/failed 结果,不能写成本站确认安全。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills