Skip to content

🛡️ Sentinel: Add strict ASCII control character validation to schemas - #798

Closed
seonghobae wants to merge 3 commits into
mainfrom
sentinel/strict-ascii-validation-9285260808069055300
Closed

🛡️ Sentinel: Add strict ASCII control character validation to schemas#798
seonghobae wants to merge 3 commits into
mainfrom
sentinel/strict-ascii-validation-9285260808069055300

Conversation

@seonghobae

@seonghobae seonghobae commented Aug 9, 2026

Copy link
Copy Markdown
Collaborator

🚨 Severity: HIGH

💡 Vulnerability: User-provided string fields in Pydantic schemas intended for identifiers or names lacked strict validation against ASCII control characters, only relying on standard length constraints (min_length, max_length).

🎯 Impact: This exposes the system to potential Log Injection (CRLF injection), Null Byte Injection, or terminal escape sequence injection if these malicious string inputs are ingested and subsequently logged, rendered, or passed to execution environments.

🔧 Fix: Enforced explicit regex pattern matching (pattern=r"^[^\x00-\x1F\x7F]+$") on specific Pydantic string fields (e.g., DiagramViewCreateIn.name, TableAnnotationUpsertIn.schema_name, TableAnnotationUpsertIn.relation_name, and ApiKeyCreateIn.key_name) that do not legitimately require multiline inputs or control characters.

✅ Verification: Validated changes using ruff check and ensured all 379 backend test cases continue to pass (cd backend && PYTHONPATH=. uv run pytest tests/).


PR created automatically by Jules for task 9285260808069055300 started by @seonghobae

Summary by CodeRabbit

  • 보안 개선

    • 다이어그램 이름, 테이블 식별자, API 키 이름에 ASCII 제어 문자를 사용할 수 없도록 검증을 강화했습니다.
    • 로그 주입 및 터미널 이스케이프 시퀀스 악용 위험을 줄였습니다.
  • 테스트

    • 제어 문자가 포함된 입력이 올바르게 거부되는지 검증하는 테스트를 추가했습니다.
  • 문서

    • 관련 보안 취약점과 예방 방법을 문서화했습니다.

Enforced regex pattern `^[^\x00-\x1F\x7F]+$` on string fields intended for identifiers (e.g., `DiagramViewCreateIn.name`, `TableAnnotationUpsertIn.schema_name`, `ApiKeyCreateIn.key_name`) to prevent log injection and terminal escape sequence vulnerabilities.
@google-labs-jules

Copy link
Copy Markdown

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@coderabbitai

coderabbitai Bot commented Aug 9, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Pydantic 입력 스키마의 이름 및 식별자 필드가 ASCII 제어 문자와 DEL 문자를 거부하도록 변경했습니다. 관련 검증 테스트와 보안 지침도 추가했습니다.

Changes

제어 문자 입력 검증

Layer / File(s) Summary
스키마 검증 및 회귀 테스트
backend/app/schemas.py, backend/tests/test_schema_validation.py, .jules/sentinel.md
DiagramViewCreateIn.name, TableAnnotationUpsertIn.schema_name, TableAnnotationUpsertIn.relation_name, ApiKeyCreateIn.key_name에 제어 문자 거부 패턴을 추가했습니다. 기존 필수값 및 길이 제한은 유지합니다. 개행, 캐리지 리턴, 이스케이프, NUL, DEL 문자 입력에 대한 ValidationError 테스트와 보안 지침을 추가했습니다.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

🚥 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 제목은 선택된 Pydantic 스키마에 ASCII 제어 문자 검증을 추가하는 주요 변경 사항을 명확하게 설명합니다.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch sentinel/strict-ascii-validation-9285260808069055300

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

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

Please review the current exact head afc1f8754dfa1ea1c982525a5abb1f45d085c4c8, including the newly added adversarial control-character regression coverage.

@coderabbitai

coderabbitai Bot commented Aug 9, 2026

Copy link
Copy Markdown

@seonghobae I will review commit afc1f8754dfa1ea1c982525a5abb1f45d085c4c8, including the control-character regression coverage.

✅ 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.

Enforced regex pattern `^[^\x00-\x1F\x7F]+$` on string fields intended for identifiers (e.g., `DiagramViewCreateIn.name`, `TableAnnotationUpsertIn.schema_name`, `ApiKeyCreateIn.key_name`) to prevent log injection and terminal escape sequence vulnerabilities.

@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.

🧹 Nitpick comments (1)
backend/tests/test_schema_validation.py (1)

47-80: 🔒 Security & Privacy | 🔵 Trivial | ⚡ Quick win

ASCII 제어 문자 범위의 경계 테스트를 보강해 주세요.

현재 각 테스트는 \x00, \n, \r, \x1b, \x7f만 사용합니다. 정규식 범위의 끝점인 \x1f가 빠져 있습니다. 범위 끝점 회귀를 검출하려면 최소한 \x1f를 추가하세요. 가능하면 \x00부터 \x1f까지와 \x7f를 모두 파라미터화하세요.

최소 수정 예시
-@pytest.mark.parametrize("control_character", ["\x00", "\n", "\r", "\x1b", "\x7f"])
+@pytest.mark.parametrize("control_character", ["\x00", "\n", "\r", "\x1b", "\x1f", "\x7f"])

세 파라미터화 테스트에 동일하게 적용하세요.

As per coding guidelines, **/*.{py,ts,tsx} 파일의 동작 변경에는 focused test를 추가하거나 갱신해야 합니다.

🤖 Prompt for 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.

In `@backend/tests/test_schema_validation.py` around lines 47 - 80, Expand the
control_character parameterization in
test_diagram_view_name_rejects_ascii_control_characters,
test_table_annotation_identifiers_reject_ascii_control_characters, and
test_api_key_name_rejects_ascii_control_characters to cover the full ASCII
control range \x00 through \x1f plus \x7f, preserving the existing validation
assertions.

Source: Coding guidelines

🤖 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.

Nitpick comments:
In `@backend/tests/test_schema_validation.py`:
- Around line 47-80: Expand the control_character parameterization in
test_diagram_view_name_rejects_ascii_control_characters,
test_table_annotation_identifiers_reject_ascii_control_characters, and
test_api_key_name_rejects_ascii_control_characters to cover the full ASCII
control range \x00 through \x1f plus \x7f, preserving the existing validation
assertions.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: abbb714b-bef3-45e7-a0ee-215c9c61ea53

📥 Commits

Reviewing files that changed from the base of the PR and between 72afe6d and afc1f87.

📒 Files selected for processing (3)
  • .jules/sentinel.md
  • backend/app/schemas.py
  • backend/tests/test_schema_validation.py

Copy link
Copy Markdown
Collaborator Author

Closing this branch as superseded by #699. Both PRs target the same protected-base tip (72afe6db712b145baaba084f64a1ff4fb36d9fd0) and harden the same DiagramViewCreateIn.name, TableAnnotationUpsertIn.schema_name, TableAnnotationUpsertIn.relation_name, and ApiKeyCreateIn.key_name control-character boundary. #699 carries the stronger maintained regression contract: every U+0000–U+001F control plus U+007F at beginning/middle/end, realistic multilingual/supplementary-plane valid names, preserved multiline annotation bodies, and the associated doctoring. That also subsumes the current CodeRabbit request on this PR to broaden the ASCII-control boundary coverage. Keeping both branches open would duplicate the same security repair and review surface; #699 is the integration candidate.

@seonghobae seonghobae closed this Aug 9, 2026
@google-labs-jules

Copy link
Copy Markdown

Closing this branch as superseded by #699. Both PRs target the same protected-base tip (72afe6db712b145baaba084f64a1ff4fb36d9fd0) and harden the same DiagramViewCreateIn.name, TableAnnotationUpsertIn.schema_name, TableAnnotationUpsertIn.relation_name, and ApiKeyCreateIn.key_name control-character boundary. #699 carries the stronger maintained regression contract: every U+0000–U+001F control plus U+007F at beginning/middle/end, realistic multilingual/supplementary-plane valid names, preserved multiline annotation bodies, and the associated doctoring. That also subsumes the current CodeRabbit request on this PR to broaden the ASCII-control boundary coverage. Keeping both branches open would duplicate the same security repair and review surface; #699 is the integration candidate.

Understood. Acknowledging that this work is superseded by #699 and stopping work on this task.

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.

1 participant