Skip to content

fix: enforce HTTP Problem response redaction - #1222

Merged
kang-heewon merged 1 commit into
trunkfrom
issue-1172-problem-redaction
Jul 6, 2026
Merged

fix: enforce HTTP Problem response redaction#1222
kang-heewon merged 1 commit into
trunkfrom
issue-1172-problem-redaction

Conversation

@kang-heewon

@kang-heewon kang-heewon commented Jul 5, 2026

Copy link
Copy Markdown
Member

Fixes #1172

Summary

  • Enforce registry-backed HTTP Problem redaction through a shared transport serializer.
  • Apply the same redaction to direct ErrorHandler responses and exception-filter Problem Details, including async filters and application/problem+json Response bodies.
  • Fail closed for malformed application/problem+json filter responses, scrub stale body validator headers, and preserve safe trace/request/telemetry correlation metadata.
  • Document the public extension allowlist and add a changeset.

Verification

  • COREPACK_ENABLE_DOWNLOAD_PROMPT=0 corepack pnpm --filter @croco/transports-http exec vitest run src/tests/ErrorHandler.spec.ts --reporter=verbose
  • COREPACK_ENABLE_DOWNLOAD_PROMPT=0 corepack pnpm --filter @croco/transports-http exec vitest run src/tests/PipelineRunner.spec.ts --reporter=verbose
  • COREPACK_ENABLE_DOWNLOAD_PROMPT=0 corepack pnpm --filter @croco/transports-http test
  • COREPACK_ENABLE_DOWNLOAD_PROMPT=0 corepack pnpm --filter @croco/transports-http typecheck
  • COREPACK_ENABLE_DOWNLOAD_PROMPT=0 corepack pnpm --filter @croco/transports-http build
  • COREPACK_ENABLE_DOWNLOAD_PROMPT=0 corepack pnpm --filter @croco/problems-core test
  • COREPACK_ENABLE_DOWNLOAD_PROMPT=0 corepack pnpm --filter @croco/problems-core typecheck
  • COREPACK_ENABLE_DOWNLOAD_PROMPT=0 corepack pnpm --filter @croco/problems-core build
  • COREPACK_ENABLE_DOWNLOAD_PROMPT=0 corepack pnpm --filter @croco/docs build
  • COREPACK_ENABLE_DOWNLOAD_PROMPT=0 corepack pnpm check
  • COREPACK_ENABLE_DOWNLOAD_PROMPT=0 corepack pnpm pr-review-companion -- --base origin/trunk --head HEAD --run-required-checks
  • git diff --check

Summary by CodeRabbit

  • 새 기능

    • HTTP 오류 응답에서 공개 가능한 정보만 노출되도록 응답 마스킹 규칙이 강화되었습니다.
    • 문제 응답의 표준 필드와 추가 확장 정보가 더 일관된 방식으로 전달됩니다.
  • 버그 수정

    • 민감한 확장 값, 토큰, 내부 진단 정보가 응답에 포함되지 않도록 개선되었습니다.
    • 필터가 반환하는 문제 응답에서도 헤더와 본문 처리 규칙이 더 엄격해졌습니다.
  • 문서

    • 오류 응답 정책과 공개 확장 허용 범위에 대한 안내가 업데이트되었습니다.

@coderabbitai

coderabbitai Bot commented Jul 5, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@kang-heewon, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 41 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: b1d95dcf-9c86-4111-b133-004bfea83bd6

📥 Commits

Reviewing files that changed from the base of the PR and between 8985d2d and 7eec699.

⛔ Files ignored due to path filters (1)
  • packages/problems-core/src/generated/problem-code-registry.ts is excluded by !**/generated/**
📒 Files selected for processing (14)
  • .changeset/http-problem-redaction.md
  • docs/problem-code-registry.json
  • packages/docs/src/content/docs/api/problems-core/src/variables/CROCO_PROBLEM_CODE_REGISTRY.md
  • packages/docs/src/content/docs/api/transports-http/src/classes/ErrorHandler.md
  • packages/docs/src/content/docs/en/reference/problem-recovery-cookbook.md
  • packages/problems-core/README.md
  • packages/transports-http/README.md
  • packages/transports-http/src/libs/ErrorHandler.ts
  • packages/transports-http/src/libs/PipelineRunner.ts
  • packages/transports-http/src/libs/problemResponseSerializer.ts
  • packages/transports-http/src/tests/ErrorHandler.spec.ts
  • packages/transports-http/src/tests/PipelineRunner.spec.ts
  • scripts/static-misuse-empty-catch-allowlist.json
  • tsconfig/contract-strict.baseline.json
📝 Walkthrough

Walkthrough

HTTP 응답 경계에서 Problem 직렬화 시 등록된 레지스트리 기반 레딕션 정책을 적용하는 유틸이 추가되었습니다. ErrorHandler와 PipelineRunner가 이를 사용해 Problem 응답과 필터 반환값을 마스킹하고, 관련 문서·테스트·정적 기준이 함께 갱신되었습니다.

Changes

Problem 레딕션 강제 구현

Layer / File(s) Summary
레딕션 정책 및 문서
.changeset/http-problem-redaction.md, packages/problems-core/README.md, packages/transports-http/README.md, docs/problem-code-registry.json, packages/docs/src/content/docs/en/reference/problem-recovery-cookbook.md
redaction policy, 공개 확장 allowlist, RFC 7807/상관관계 필드 보호 규칙과 참조 위치가 문서화·동기화됨.
problemResponseSerializer 유틸
packages/transports-http/src/libs/problemResponseSerializer.ts
createHttpProblemDetails, redactHttpProblemDetailsBody 및 정책 해석·필드 필터링·타입가드 헬퍼가 신규 구현됨.
ErrorHandler 응답 생성/레딕션
packages/transports-http/src/libs/ErrorHandler.ts, packages/docs/src/content/docs/api/transports-http/src/classes/ErrorHandler.md
handleProblem이 새 유틸 기반으로 응답을 생성하고, createFilterResponseBody가 필터 반환 바디를 레딕션 처리하며, API 문서에 새 메서드 시그니처가 추가됨.
PipelineRunner 비동기 필터 응답 처리
packages/transports-http/src/libs/PipelineRunner.ts
runFilters가 비동기로 전환되고, problem+json 응답을 createRedactedFilterResponse로 재생성하며 헤더 복사 로직이 개선됨.
검증 및 기준 동기화
packages/transports-http/src/tests/ErrorHandler.spec.ts, packages/transports-http/src/tests/PipelineRunner.spec.ts, scripts/static-misuse-empty-catch-allowlist.json, tsconfig/contract-strict.baseline.json
레딕션 테스트가 갱신되고, static empty-catch allowlist와 contract baseline의 관련 항목이 조정됨.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Filter
  participant PipelineRunner
  participant ErrorHandler
  participant problemResponseSerializer
  participant Client

  Filter-->>PipelineRunner: Response(application/problem+json) or FilterResponse
  PipelineRunner->>PipelineRunner: clone().json() 파싱
  PipelineRunner->>ErrorHandler: createFilterResponseBody(error, body, ctx)
  ErrorHandler->>problemResponseSerializer: redactHttpProblemDetailsBody(body, options)
  problemResponseSerializer-->>ErrorHandler: redacted ProblemDetails
  ErrorHandler-->>PipelineRunner: metadata 병합된 body
  PipelineRunner-->>Client: 새 JSON Response(헤더 필터링)
Loading

Related issues: #1172

Suggested labels: review_needed_junior_swe, review_depth_deep

Suggested reviewers: (분석 정보 부족으로 특정 리뷰어 추천 불가)

Poem

토끼가 문제 상자를 열어보니 🐰
비밀 토큰은 어디에도 없네
allowlist만 살짝 내밀고
operator만 아는 이야기는
로그 속에 고이 숨겨두었지

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 제목이 HTTP Problem 응답 레딧션 강제라는 핵심 변경을 간결하게 잘 요약합니다.
Linked Issues check ✅ Passed HTTP Problem 직렬화의 레딧션 정책 적용, allowlist, 안전한 상관 메타데이터 보존, 관련 테스트/문서화가 모두 반영되었습니다.
Out of Scope Changes check ✅ Passed 변경은 코드, 테스트, 문서, changeset 및 관련 설정으로 한정되며 목표와 무관한 변경은 보이지 않습니다.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch issue-1172-problem-redaction

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@kang-heewon
kang-heewon force-pushed the issue-1172-problem-redaction branch from 5151398 to 27f78dc Compare July 5, 2026 08:51
@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown

📊 Benchmark Results

✅ All benchmarks passed

Benchmark p75 Threshold Baseline vs Baseline Status Notes
CrocoApp constructor 7.3μs 30.0ms 8.2μs -11.2% -
CrocoApp lambdaHandler (10 controllers) 302.9μs 50.0ms 258.4μs +17.2% -
Lambda cold-start simulation 438.3μs 80.0ms 418.1μs +4.8% -
Lambda cold-start with headers 369.5μs 80.0ms 369.7μs -0.0% -
Lambda cold-start with binary body 341.0μs 80.0ms 339.1μs +0.6% -
Lambda cold-start with query params 303.5μs 80.0ms 301.3μs +0.7% -
Lambda cold-start with authorizer context 305.3μs 80.0ms 299.8μs +1.8% -
Lambda cold-start realistic scenario 300.8μs 80.0ms 299.2μs +0.5% -
EventBusConfig.start (10 handlers) 1.4μs 10.0ms 1.4μs -1.5% -
EventPublisher.publishNow single event 1.6μs 2.0ms 1.7μs -2.9% -
DefaultHandlerResolver.resolve × 10 0.1μs 5.0ms 0.1μs -11.2% -
Container.get singleton (cold) 68.7μs 5.0ms 70.3μs -2.3% -
Container.register × 50 components 3.2ms 10.0ms 3.2ms +0.5% -
Container.validate (50 components) 3.2ms 20.0ms 3.4ms -6.5% -
Container.get singleton (warm) 1.6μs 500.0μs 1.6μs +0.6% -
TelemetryRuntime.init (lambda preset) 1.9μs 200.0ms 1.1ms -99.8% -
lambdaPreset config creation 1.4μs 2.0ms 1.4μs -0.6% -

Updated: 2026-07-06T04:47:30.342Z · Commit: 7234ae3

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/transports-http/src/libs/PipelineRunner.ts`:
- Line 30: Update the BODY_SPECIFIC_RESPONSE_HEADERS set in PipelineRunner to
also include entity-validation headers that become stale after body
reserialization, such as ETag, Digest/Content-Digest, and Content-MD5. Make the
change where BODY_SPECIFIC_RESPONSE_HEADERS is defined so the response header
cleanup logic removes these headers along with the existing content-length and
content-encoding entries.
- Around line 231-245: `PipelineRunner` currently returns the original response
on `application/problem+json` parse failures or non-object/problem-unknown
bodies, which can bypass redaction. Update the response handling in
`PipelineRunner` so that when the content type is `application/problem+json`,
any JSON parse failure, non-record payload, or unrecognized Problem Details
shape falls back to the `ErrorHandler`-redacted response instead of returning
the raw response. Keep the logic localized around `response.clone().json()`,
`isRecord`, and `errorHandler.createFilterResponseBody(...)`, and only preserve
the original response for non-Problem Details content.

In `@packages/transports-http/src/libs/problemResponseSerializer.ts`:
- Around line 147-158: `extractProblemDetailsExtensions` can be polluted by a
`__proto__` key coming from untrusted `ProblemDetails` input, because it writes
into a plain `{}` accumulator. Update this helper to defensively ignore
`__proto__` (and any similar prototype-polluting keys) when building the
extensions object, and keep the change localized to
`extractProblemDetailsExtensions`/`RESERVED_PROBLEM_EXTENSION_FIELDS` so the
rest of `problemResponseSerializer` stays unchanged.
- Around line 169-192: The `toFallbackCategory` helper is collapsing all 422
responses into `ProblemCategory.BusinessRuleViolation`, which can misclassify
fallback redaction when the original category was `ValidationError`. Update the
fallback handling in `problemResponseSerializer` so 422 is resolved more
deliberately, using the available problem context (for example the source
problem or registered code) instead of always defaulting to
`BusinessRuleViolation`. Keep the change localized to `toFallbackCategory` and
the nearby fallback resolution path so `ProblemCategory.ValidationError` and
`ProblemCategory.BusinessRuleViolation` remain distinguishable when possible.

In `@packages/transports-http/src/tests/PipelineRunner.spec.ts`:
- Around line 285-343: Add a regression test in PipelineRunner.spec around the
existing redaction case for async exception filters to cover malformed
application/problem+json responses that fail parsing, are non-object, or
otherwise unrecognized. Use the current createRunner, HttpExecutionContext, and
filter catch path to verify the fallback Response still redacts the original
body and does not leak raw payload fields. Also assert that header scrubbing
removes ETag and Digest-family headers in addition to the existing
Content-Encoding and Content-Length checks.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 1ff687a3-655e-4fb9-9159-c9f84c984f2a

📥 Commits

Reviewing files that changed from the base of the PR and between cd98718 and 5151398.

📒 Files selected for processing (8)
  • .changeset/http-problem-redaction.md
  • packages/problems-core/README.md
  • packages/transports-http/README.md
  • packages/transports-http/src/libs/ErrorHandler.ts
  • packages/transports-http/src/libs/PipelineRunner.ts
  • packages/transports-http/src/libs/problemResponseSerializer.ts
  • packages/transports-http/src/tests/ErrorHandler.spec.ts
  • packages/transports-http/src/tests/PipelineRunner.spec.ts

Comment thread packages/transports-http/src/libs/PipelineRunner.ts Outdated
Comment thread packages/transports-http/src/libs/PipelineRunner.ts Outdated
Comment thread packages/transports-http/src/libs/problemResponseSerializer.ts
Comment thread packages/transports-http/src/libs/problemResponseSerializer.ts Outdated
Comment thread packages/transports-http/src/tests/PipelineRunner.spec.ts
@kang-heewon
kang-heewon force-pushed the issue-1172-problem-redaction branch 2 times, most recently from a6480f3 to ca207ac Compare July 5, 2026 09:14
@kang-heewon
kang-heewon force-pushed the issue-1172-problem-redaction branch 2 times, most recently from d368d28 to 8985d2d Compare July 5, 2026 10:11
@kang-heewon

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/transports-http/src/libs/PipelineRunner.ts`:
- Around line 216-223: In PipelineRunner’s isFilterResponse branch, the
FilterResponse path is still returning a jsonResponse even when
createFilterResponseBody() falls back to the original body, so update this flow
to fail closed like the Response path by routing schema-mismatched
application/problem+json cases through handleError() instead of exposing the
payload. Use the existing nextError, errorHandler.createFilterResponseBody(),
httpCtx.jsonResponse(), and copyFilterResponseHeaders() logic in PipelineRunner
to detect the unsafe fallback and return the handled error response, and add a
regression test covering this FilterResponse case.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 96ed3427-17de-493b-bf78-33ca9f0685ee

📥 Commits

Reviewing files that changed from the base of the PR and between 5151398 and 8985d2d.

⛔ Files ignored due to path filters (1)
  • packages/problems-core/src/generated/problem-code-registry.ts is excluded by !**/generated/**
📒 Files selected for processing (14)
  • .changeset/http-problem-redaction.md
  • docs/problem-code-registry.json
  • packages/docs/src/content/docs/api/problems-core/src/variables/CROCO_PROBLEM_CODE_REGISTRY.md
  • packages/docs/src/content/docs/api/transports-http/src/classes/ErrorHandler.md
  • packages/docs/src/content/docs/en/reference/problem-recovery-cookbook.md
  • packages/problems-core/README.md
  • packages/transports-http/README.md
  • packages/transports-http/src/libs/ErrorHandler.ts
  • packages/transports-http/src/libs/PipelineRunner.ts
  • packages/transports-http/src/libs/problemResponseSerializer.ts
  • packages/transports-http/src/tests/ErrorHandler.spec.ts
  • packages/transports-http/src/tests/PipelineRunner.spec.ts
  • scripts/static-misuse-empty-catch-allowlist.json
  • tsconfig/contract-strict.baseline.json
💤 Files with no reviewable changes (2)
  • scripts/static-misuse-empty-catch-allowlist.json
  • tsconfig/contract-strict.baseline.json

Comment thread packages/transports-http/src/libs/PipelineRunner.ts
@kang-heewon
kang-heewon force-pushed the issue-1172-problem-redaction branch from 8985d2d to 7f9ca91 Compare July 6, 2026 04:33
@kang-heewon
kang-heewon force-pushed the issue-1172-problem-redaction branch from 7f9ca91 to 7eec699 Compare July 6, 2026 04:39
@kang-heewon
kang-heewon merged commit b228e78 into trunk Jul 6, 2026
9 checks passed
@kang-heewon
kang-heewon deleted the issue-1172-problem-redaction branch July 6, 2026 05:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[problems-core/transports-http] Enforce Problem redaction policy at HTTP response serialization

1 participant