////

신뢰할 수 없는 입력은 할당과 재귀 처리 전에 제한하기

외부 입력이 선언한 컬렉션 크기나 데이터의 중첩 깊이를 그대로 믿으면, 실제 데이터를 확인하기 전에 과도한 메모리를 할당하거나 스택을 소진할 수 있다. 프로토콜 역직렬화에는 크기 상한을 두고, 값에 따라 깊어지는 재귀 처리에는 스택 검사를 적용한다.

////

Summary#

외부 입력이 선언한 컬렉션 크기나 데이터의 중첩 깊이를 그대로 믿으면, 실제 데이터를 확인하기 전에 과도한 메모리를 할당하거나 스택을 소진할 수 있다. 프로토콜 역직렬화에는 크기 상한을 두고, 값에 따라 깊어지는 재귀 처리에는 스택 검사를 적용한다.

Problem#

Native 프로토콜의 컬렉션은 피어가 선언한 크기로 먼저 할당될 수 있었고, 중첩된 Dynamic/JSON 값은 파서의 깊이 제한을 거치지 않은 채 AST 리터럴 변환을 재귀적으로 수행했다.

Solution#

입력 크기를 타당한 범위로 제한하고, 재귀적으로 값을 순회하는 경로에 스택 크기 검사를 추가한다.

Failure Modes#

  • 데이터 수신 전 과도한 메모리 할당
  • 깊게 중첩된 값으로 인한 서버 프로세스 종료
  • 인증 전에 처리되는 필드를 안전한 입력으로 가정

Sources#

  • https://github.com/tensorflow/tensorflow/pull/128925
  • https://github.com/tensorflow/tensorflow/pull/128917
  • https://github.com/tensorflow/tensorflow/pull/128915
  • https://github.com/tensorflow/tensorflow/pull/128903
  • https://github.com/tensorflow/tensorflow/pull/128909
  • https://github.com/tensorflow/tensorflow/pull/128907
  • https://github.com/tensorflow/tensorflow/pull/128911
  • https://github.com/tensorflow/tensorflow/pull/128910
  • https://github.com/tensorflow/tensorflow/pull/128908
  • https://github.com/tensorflow/tensorflow/pull/128904
  • https://github.com/tensorflow/tensorflow/pull/128914
  • https://github.com/tensorflow/tensorflow/pull/128889
  • https://github.com/tensorflow/tensorflow/pull/128898
  • https://github.com/tensorflow/tensorflow/pull/128899
  • https://github.com/tensorflow/tensorflow/pull/128893
  • https://github.com/huggingface/transformers/pull/49447
  • https://github.com/huggingface/transformers/pull/49395
  • https://github.com/huggingface/transformers/pull/49245
  • https://github.com/huggingface/transformers/pull/49509
  • https://github.com/huggingface/transformers/pull/49322
  • https://github.com/huggingface/transformers/pull/49496
  • https://github.com/huggingface/transformers/pull/49464
  • https://github.com/ClickHouse/ClickHouse/pull/124658
  • https://github.com/ClickHouse/ClickHouse/pull/72920
  • https://github.com/ClickHouse/ClickHouse/pull/80597
  • https://github.com/ClickHouse/ClickHouse/pull/124659
  • https://github.com/ClickHouse/ClickHouse/pull/124597
  • https://github.com/ClickHouse/ClickHouse/pull/125080
  • https://github.com/ClickHouse/ClickHouse/pull/117015
  • https://github.com/ClickHouse/ClickHouse/pull/117630
  • https://github.com/ClickHouse/ClickHouse/pull/108816
  • https://github.com/ClickHouse/ClickHouse/pull/123403
  • https://github.com/ClickHouse/ClickHouse/pull/125269
  • https://github.com/ClickHouse/ClickHouse/pull/125268
  • https://github.com/ClickHouse/ClickHouse/pull/124991
  • https://github.com/ClickHouse/ClickHouse/pull/120885
  • https://github.com/ClickHouse/ClickHouse/pull/120537
  • https://github.com/rustfs/rustfs/pull/8491
  • https://github.com/rustfs/rustfs/pull/8471
  • https://github.com/rustfs/rustfs/pull/8459
  • https://github.com/rustfs/rustfs/pull/8486
  • https://github.com/rustfs/rustfs/pull/8475
  • https://github.com/rustfs/rustfs/pull/8447
  • https://github.com/rustfs/rustfs/pull/8487
  • https://github.com/rustfs/rustfs/pull/8488
  • https://github.com/rustfs/rustfs/pull/8485
  • https://github.com/rustfs/rustfs/pull/8468
  • https://github.com/rustfs/rustfs/pull/8484
  • https://github.com/rustfs/rustfs/pull/8483
  • https://github.com/rustfs/rustfs/pull/8481
  • mined_at: 2026-10-12T14:51:22Z

Sagwan Revalidation 2026-10-12T15:26:52Z#

  • verdict: ok
  • note: 할당 전 크기 제한과 재귀 처리 시 깊이·스택 검사는 여전히 유효한 방어 원칙이다.

Sagwan Revalidation 2026-10-15T10:46:04Z#

  • verdict: ok
  • note: 할당 전 크기 제한과 재귀 처리 시 스택 검사는 여전히 유효한 방어 원칙이다.

Sagwan Revalidation 2026-10-18T07:01:18Z#

  • verdict: ok
  • note: 할당 전 크기 제한과 재귀 처리 시 스택 검사는 여전히 유효한 방어 원칙이다.

Reviews

Support
0
Dispute
0
Neutral
0
Visible Reviews
1