Files
llm-wiki/vault/20-evidence/official-docs/owasp-logging-cheat-sheet.md
T

10 KiB
Raw Blame History

title, source_type, url, archive_url, vendor, related_branches, related_projects, tags, created
title source_type url archive_url vendor related_branches related_projects tags created
official-doc / OWASP Logging Cheat Sheet — Log Injection Defense & Sanitization Guidance official-doc https://cheatsheetseries.owasp.org/cheatsheets/Logging_Cheat_Sheet.html OWASP (Open Worldwide Application Security Project)
feature-operational-error-observability-foundation
ca-skeleton
official-doc
ca-skeleton
security
owasp
log-injection
cwe-117
2026-06-01

official-doc / OWASP Logging Cheat Sheet — Log Injection Defense & Sanitization Guidance

Layer: raw/ — 외부 자료(OWASP 공식 가이드라인)의 원문 발췌·출처 기록. 검증된 요약은 /ingestwiki/concepts/에 별도 작성. 원본은 raw에 영구 보관.

신뢰도 구분 (중요): 이 문서는 OWASP Cheat Sheet Series 에서 발행한 engineering guidance 이다. RFC·ISO·IETF 같은 규범적(normative) 국제 표준이 아니며, 특정 벤더의 공식 API 문서도 아니다. Strength 는 official-reference 로 분류한다 — 업계에서 권위 있는 참고 기준이나, 표준 준수 의무(MUST/SHALL) 를 직접 부과하는 문서는 아니다. 이 자료만으로 "표준상 의무" 를 주장할 수 없다.

Parent / 활용 branch (필수)

Branch 이 자료가 정당화하는 결정
raw/branch-notes/feature-operational-error-observability-foundation D14: inbound HTTP header (X-Request-Id, X-Correlation-Id) 값을 MDC에 반영할 때 CRLF 등 제어문자 제거(log injection / log forgery 방어 — CWE-117) 를 의무화하는 결정의 근거

출처 / Source

  • 원본 URL: https://cheatsheetseries.owasp.org/cheatsheets/Logging_Cheat_Sheet.html
  • 아카이브 URL: (미등록 — 추후 archive.org 스냅샷 추가 권장)
  • 저자 / 조직: OWASP (Open Worldwide Application Security Project) — Cheat Sheet Series
  • 발행일: 지속 갱신 (Cheat Sheet Series git repository 기반, 특정 발행일 없음)
  • 마지막 확인일: 2026-06-01

왜 저장했는지 / Why archived

feature-operational-error-observability-foundation branch 는 클라이언트가 공급하는 X-Request-Id / X-Correlation-Id HTTP 헤더 값을 MDC 에 기록한다. 이 값이 CRLF 또는 기타 제어문자를 포함하면 로그 항목이 위조(log forgery)되거나 추가 항목이 삽입(log injection)될 수 있다(CWE-117). 본 OWASP 가이드가 해당 위협을 명시하고 sanitization / output encoding 을 권고하므로, D14 결정의 외부 근거로 보관한다.

핵심 인용 / Key quotes (verbatim, 5개)

[§Event data sources] "Data may be missing, modified, forged, replayed and could be malicious it must always be treated as untrusted data." (source: line 4545 in fetched HTML)

[§Event collection] "Perform input validation on event data from other trust zones to ensure it is in the correct format (and consider alerting and not logging if there is an input validation failure)" (source: line 4700 in fetched HTML)

[§Event collection] "Perform sanitization on all event data to prevent log injection attacks e.g. carriage return (CR), line feed (LF) and delimiter characters (and optionally to remove sensitive data)" (source: line 4701 in fetched HTML)

[§Event collection] "Encode data correctly for the output (logged) format" (source: line 4702 in fetched HTML)

[§Attacks on Logs] "Because of their usefulness as a defense, logs may be a target of attacks. See also OWASP Log Injection and CWE-117." (source: line 4790 in fetched HTML — HTML anchor tags stripped from verbatim for readability; original contains <a href="https://owasp.org/www-community/attacks/Log_Injection">Log Injection</a> and <a href="https://cwe.mitre.org/data/definitions/117.html">CWE-117</a>)

추가 인용 (Accountability / log forgery):

[§Attacks on Logs — Accountability] "An attacker causes the wrong identity to be logged in order to conceal the responsible party." (source: line 4816 in fetched HTML)

Claims Extracted / 추출된 주장

이 자료가 직접 말하는 것만 claim 으로 분리한다. 내 프로젝트 적용 결론은 아래에 포함하지 않는다.

Claim ID Claim (이 자료가 직접 말하는 것) Evidence quote Strength Applies to Does not prove
OWASP-LOG-C1 다른 신뢰 영역(trust zone)에서 유래한 이벤트 데이터는 변조·위조·재전송·악성 가능성이 있으므로 항상 untrusted data 로 취급해야 한다 [§Event data sources] "Data may be missing, modified, forged, replayed and could be malicious it must always be treated as untrusted data." official-reference 외부 시스템·클라이언트·다른 서비스에서 수신한 모든 로그 이벤트 데이터 어떤 구체적 구현 기법(MDC sanitization API 등)이 "untrusted" 를 충족하는지는 직접 명시하지 않음
OWASP-LOG-C2 이벤트 컬렉션 시 다른 trust zone 에서 온 데이터에 대해 입력 유효성 검사를 수행해야 한다. 입력 유효성 검사 실패 시 로깅하지 않고 경보만 올리는 것을 고려해야 한다 [§Event collection] "Perform input validation on event data from other trust zones to ensure it is in the correct format (and consider alerting and not logging if there is an input validation failure)" official-reference 로그 이벤트 데이터 수집 레이어; 특히 외부 trust zone 유래 값 어떤 포맷이 "correct format" 인지는 애플리케이션별 정의가 필요
OWASP-LOG-C3 log injection 공격(CR, LF, 구분자 문자 등)을 막기 위해 모든 이벤트 데이터에 sanitization 을 수행해야 한다 [§Event collection] "Perform sanitization on all event data to prevent log injection attacks e.g. carriage return (CR), line feed (LF) and delimiter characters (and optionally to remove sensitive data)" official-reference 구조화 여부와 무관하게 모든 이벤트 데이터 필드 특정 charset (예: ASCII-only) 강제, 최대 길이 제한, 구체적인 sanitization 라이브러리/API 는 본 문서에서 규정하지 않음
OWASP-LOG-C4 이벤트 데이터를 출력(기록) 포맷에 맞게 올바르게 인코딩해야 한다 [§Event collection] "Encode data correctly for the output (logged) format" official-reference 로그 출력 포맷이 있는 모든 로깅 구현 (JSON, plaintext, syslog 등) 어떤 포맷에서 어떤 인코딩을 사용해야 하는지 (예: JSON string escaping 이 충분한지) 는 본 문서에서 구체적으로 명시하지 않음
OWASP-LOG-C5 로그는 방어 도구로서의 가치 때문에 공격 대상이 되며, 구체적 위협으로 CWE-117 이 명시되어 있다 [§Attacks on Logs] "Because of their usefulness as a defense, logs may be a target of attacks. See also OWASP Log Injection and CWE-117." official-reference 모든 로깅 시스템 CWE-117 의 완화 기법이 무엇인지, structured logging 이 injection 을 완전히 막는지는 본 문서에서 직접 주장하지 않음

Usage Boundaries / 적용 경계

  • 이 자료가 직접 증명하는 것:
    • OWASP-LOG-C1: 외부 시스템(다른 trust zone)에서 수신한 데이터(HTTP 헤더 값 포함)는 untrusted 로 취급해야 한다.
    • OWASP-LOG-C3: CR / LF / 구분자 문자에 대한 sanitization 이 log injection 방어의 명시된 요구사항이다.
    • OWASP-LOG-C5: log injection 은 OWASP 에서 CWE-117 과 연결하여 실제 위협으로 인정한다.
  • 이 자료가 증명하지 않는 것:
    • structured logging (예: JSON 로그) 자체가 log injection 을 완전히 방지한다는 주장 — 본 문서에 없음.
    • MDC 에 저장하는 값의 최대 허용 길이나 charset(예: printable ASCII only) 구체 규정 — 본 문서에 없음.
    • Java / Spring 에서의 특정 sanitization API(PatternLayout, %replace, logback 설정 등) — 본 문서 범위 밖.
    • OWASP guidance 가 normative standard(MUST/SHALL 의무) 임 — guidance/cheat sheet 이지 규범적 표준이 아님.
  • 내 프로젝트에 적용하려면 추가 확인이 필요한 것:
    • ca-skeleton MDC filter 에서 X-Request-Id / X-Correlation-Id 헤더 값에 CR/LF/제어문자 strip 구현 (Logback MDC 는 자동 처리하지 않음 — 별도 filter 필요).
    • 길이 제한(예: 최대 256자) 이 OWASP 권고에서는 규정되지 않으므로, 이는 내부 design decision 으로만 표현해야 함 (UNSUPPORTED_IMPL_DECISION).
    • structured JSON logging(Logstash encoder 등) 이 JSON string escaping 을 자동 적용하더라도, MDC key→value 에 개행문자가 있으면 JSON 내부 \n 로 escape 될 뿐 log injection 위협 자체는 여전히 존재할 수 있음 — 별도 검증 필요.

메모 / Notes

  • OWASP Logging Cheat Sheet 는 특정 길이 제한이나 charset allowlist 를 직접 규정하지 않는다. MDC 값에 길이/charset 제한을 두는 것은 내부 design choice (UNSUPPORTED_IMPL_DECISION) — ca-skeleton branch 에서 별도 trade-off 명시 필요.
  • CWE-117 원문 (https://cwe.mitre.org/data/definitions/117.html) 은 본 자료에서 인용만 하고 있다. CWE-117 의 완화 기법 상세는 CWE 원문을 별도 raw 자료로 등록해야 함 (현재 미등록).
  • structured logging(JSON output) 이 log injection 의 완화책이라는 주장은 본 문서에 없음. 이를 주장하려면 별도 official 근거 필요.
  • "An attacker causes the wrong identity to be logged in order to conceal the responsible party." (line 4816) — 이 문장은 log forgery 의 결과로 잘못된 identity 가 기록되는 위협을 설명한다. X-Correlation-Id 헤더 값이 attacker-controlled 이면 동일한 위협이 발생한다.