본문으로 건너뛰기
Skillpedia
보안19k · #10503

xerj-security-audit

하는 일

코드베이스를 색인하고 위험한 함수 호출을 하나씩 확인해 보안 문제를 검토합니다. 검색이 완전했다는 기록을 남기므로, 빠른 스캔이 아닌 근거 있는 감사를 원하는 개발자와 보안 검토자를 위한 스킬입니다.

사용하는 경우

  • ✓전체 범위를 기록으로 남기며 PHP 앱이나 플러그인의 보안을 검토하고 싶을 때.
  • ✓코드베이스의 위험한 호출을 모두 나열해야 할 때.
  • ✓나중에 조회할 수 있도록 발견 사항을 원장에 기록하고 싶을 때.

스킬 링크

https://github.com/xerj-org/xerj/blob/main/docs/case-studies/wordpress-security-audit/skill/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/xerj-org/xerj/blob/main/docs/case-studies/wordpress-security-audit/skill/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“이 PHP 플러그인의 보안을 검토해 주세요. 위험한 함수 호출을 하나도 놓치지 않았다는 것을 증명해 주세요.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

이 스킬은 코드를 한 번 색인하고, 알려진 위험 함수를 정리한 뒤, 구문 트리 검사로 각 호출 위치를 찾습니다. 그 결과를 단순 텍스트 검색과 대조해 빠진 것이 없음을 보이고, 발견 사항을 검색 가능한 원장에 기록합니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

XERJ whitebox security audit

Run a security review where XERJ is the agent's second brain: index the code once, then interrogate it — never load whole files. The deliverable is a defensible coverage claim, not a vibe. Scripts referenced below live in docs/case-studies/wordpress-security-audit/sink-census/ (copy them alongside this skill to reuse in another repo).

When to use

  • "Security-review this codebase / WordPress plugin / PHP app with coverage."
  • "Find the dangerous calls / sinks and prove we didn't miss any."
  • "Run the sink census / audit ledger."

Prerequisites (state them, then set up)

  • XERJ running, ES-compatible, on http://127.0.0.1:9200 (xerj --insecure --data-dir ./data).
  • pip install tree-sitter tree-sitter-php (+ the grammar for the target language).
  • The target source tree on disk.

The loop (do these in order; report honestly at each step)

1. Map the dangerous functions (knowledge)

Use php_dangerous_functions.json — 275 PHP built-ins/constructs across 28 categories (command/code exec, unserialize, include loaders, file r/w/delete, SSRF, SQL drivers, XXE, callables, variable-injection, reflection, weak crypto/ random, type-juggling, …), each with vuln class + the taint-relevant argument. For another framework/language, extend this map — it is data, not code.

2. Census every call site (AST)

python3 sink_census.py <src> parses every file with tree-sitter and records

2b. Census the dangerous PATTERNS (the class a sink list misses)

python3 pattern_census.py <src> AST-detects the non-function vulns — loose == / magic-hash, non-strict in_array, strcmp-with-array (?login[]=), @ suppression, variable-variables, unsafe setcookie, switch-on-request, Host-header trust, ORDER-BY injection — into wppatterns. Semantic classes a census can't decide (SQL truncation, charset SQLi, second-order, phar, TOCTOU, upload-exec, is_numeric bypass, regex-anchor, session-fixation, wrong-context XSS) are catalogued in php_dangerous_patterns.json with detection guidance and swept by reasoning. FULL REFERENCE: PHP-SECURITY-GUIDE.md — every function AND pattern mapped to attack + detection + safe recipe. every call site of a catalogued function (calls, methods, constructs like echo/include/backtick, new ReflectionFunction). tree-sitter captures real calls regardless of formatting/namespacing — grep cannot.

3. PROVE coverage (the guarantee — do not skip)

The census reconciles every grep occurrence against the AST, using AST string/comment/inline-HTML node ranges as the oracle. A clean run prints:

UNEXPLAINED: 0  => coverage PROVEN (0 gaps)

If UNEXPLAINED > 0, EVERY residual must be resolved (it is either a real call the extractor missed — fix the catalog/node-handling — or a proven non-call). Never report coverage while residuals are unexplained.

4. Index + triage (XERJ wpsinks)

The census bulk-indexes one doc per call site (file,line,fn,class,arg). Query the risk profile; the rare high-value classes are the must-review set (in WP core: RCE-command 11, deserialization 13, SQL 200, SSRF 107). You can now guarantee you've seen every one.

5. AI-enrich into a ledger (enrich_pipeline.py)

For each high-risk site: read the arg + enclosing code, decide reachable (request/cache/trusted/literal), guarded (which defense), severity, and a verdict; write it back to wpsinks. This is the embedding-pipeline analogue, but the enrichment is reasoned security judgement, and it accretes across runs. Enrich 100% of the rare classes; queue the long tail.

5b. Trace any sink through the API (trace_sink.py <file> <line>)

Joins wpsinks -> wpaudit -> wpauthz -> reverse callers with NO local file access: the sink + verdict, the enclosing function's sources/sinks/sanitizer, its authz guards, and who calls it + whether they read a request source. The verdict flags a SOURCE->SINK candidate when a source and an unsanitized sink coexist in a function. (Reverse callers scan _source calls arrays because of the array-term engine bug, and restrict common method names like load/query to the same file to avoid class collision.)

6. Reason about the real bugs (the parts a census can't see)

Sink coverage ≠ total coverage. Also sweep, using the other detectors in the case study: object-scoped authorization / IDOR (wp_authz_graph.py, wp_checkuse_idor.py), validator completeness (wp_ssrf_ranges.py — an incomplete

자주 묻는 질문

범위 주장은 무슨 뜻인가요?

구문 검사로 찾은 위험 호출은 단순 텍스트 검색과 교차 확인되므로, 검토에 빈틈이 없음을 보여 줍니다.

어떤 언어를 지원하나요?

주로 PHP를 다루며, 다른 언어는 각자의 문법과 함수 목록이 필요합니다.

실행 중인 서비스가 필요한가요?

네. 로컬 검색 노드가 실행 중이어야 하며, tree-sitter 파싱 패키지가 설치되어 있어야 합니다.

상세 정보

작성자의 원본 설명

Coverage-guaranteed whitebox security audit of a codebase using XERJ + tree-sitter AST. Use when the user wants to security-review PHP (or other-language) code with a provable "we enumerated every dangerous call" guarantee, or asks to run the WordPress-style sink census / audit. Drives an index-once, query-read-reason loop; proves zero gaps against grep; enriches findings into a queryable ledger.

repo: xerj-org/xerj

인기도

GitHub 스타
19k
순위
#10503
라이선스
Apache-2.0
업데이트
2026. 11. 2.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬