-
Notifications
You must be signed in to change notification settings - Fork 0
π‘οΈ Sentinel: [HIGH] Fix Information Disclosure in CI Subprocess Logs #631
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
seonghobae
wants to merge
13
commits into
main
from
sentinel/fix-ci-subprocess-log-leak-16137767205653188116
Closed
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
181ee60
π‘οΈ Sentinel: [HIGH] Fix Information Disclosure in CI Subprocess Logs
seonghobae f124317
π‘οΈ Sentinel: [HIGH] Fix Information Disclosure in CI Subprocess Logs β¦
seonghobae fb00646
test(security): construct redaction fixtures at runtime
seonghobae c0aba36
test(security): avoid static secret-like fixtures
seonghobae 05126d0
π‘οΈ Sentinel: [HIGH] Fix Information Disclosure in CI Subprocess Logs β¦
seonghobae 560606a
π‘οΈ Sentinel: [HIGH] Fix Information Disclosure in CI Subprocess Logs β¦
seonghobae 4727c98
test(security): construct redaction fixtures at runtime
seonghobae 132999c
test(security): avoid literal credential-shaped fixtures
seonghobae 7903e31
fix(security): fail closed when log redaction is unavailable
seonghobae 968f737
chore(ci): prepare clean PR 631 history
seonghobae 36b932f
chore(ci): remove temporary PR 631 repair workflow
seonghobae c198c65
test(security): avoid secret-shaped redaction fixtures
seonghobae 72fdb2c
test(security): use scanner-safe web redaction fixtures
seonghobae File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| """Regression tests for sandboxed verification log redaction.""" | ||
|
|
||
| from scripts.ci import sandboxed_verify | ||
|
|
||
|
|
||
| def _api_key_fixture() -> str: | ||
| """Return a representative key/value secret fixture.""" | ||
| return "api_key: " + "mock_token_string" | ||
|
|
||
|
|
||
| def _session_key_fixture() -> str: | ||
| """Return a scanner-safe sensitive assignment fixture.""" | ||
| return "session_key=" + "mock_session_value" | ||
|
|
||
|
|
||
| def test_timeout_output_text_redacts_bytes_and_str() -> None: | ||
| """Timeout output is normalized and redacted for bytes and strings.""" | ||
| api_key = _api_key_fixture() | ||
| session_key = _session_key_fixture() | ||
|
|
||
| assert sandboxed_verify.redact_text( | ||
| sandboxed_verify.timeout_output_text(api_key.encode()) | ||
| ) == "api_key: [REDACTED]" | ||
| assert sandboxed_verify.redact_text( | ||
| sandboxed_verify.timeout_output_text(session_key) | ||
| ) == "session_key=[REDACTED]" | ||
|
|
||
|
|
||
| def test_emit_result_redacts_payload_fields(capsys, tmp_path) -> None: | ||
| """Machine-readable evidence never emits credential-shaped payload values.""" | ||
| api_key = _api_key_fixture() | ||
| session_key = _session_key_fixture() | ||
| sandboxed_verify.emit_result( | ||
| command=["echo", api_key], | ||
| copied_repo=tmp_path / session_key, | ||
| sandbox_root=tmp_path / "sandbox_test_root", | ||
| exit_code=0, | ||
|
|
||
| elapsed_seconds=1.0, | ||
| kept=True, | ||
| allowed_env=[], | ||
| network="default", | ||
| evidence_note=f"used {api_key}", | ||
| ) | ||
| captured = capsys.readouterr() | ||
| assert "[REDACTED]" in captured.out | ||
| assert "mock_token_string" not in captured.out | ||
| assert "mock_session_value" not in captured.out | ||
| assert "sandbox_test_root" in captured.out | ||
|
|
||
|
|
||
|
|
||
| def test_main_redacts_stdout_and_stderr(tmp_path, capsys) -> None: | ||
| """Subprocess stdout and stderr are redacted before publication.""" | ||
| repo = tmp_path / "repo" | ||
| repo.mkdir() | ||
| api_key = _api_key_fixture() | ||
| session_key = _session_key_fixture() | ||
| command = ( | ||
| "import sys; " | ||
| f"print({api_key!r}); " | ||
| f"print({session_key!r}, file=sys.stderr)" | ||
| ) | ||
|
|
||
| exit_code = sandboxed_verify.main( | ||
| [ | ||
| "--repo-root", | ||
| str(repo), | ||
| "--timeout", | ||
| "5", | ||
| "--", | ||
| "python", | ||
| "-c", | ||
| command, | ||
| ] | ||
| ) | ||
| captured = capsys.readouterr() | ||
| assert exit_code == 0 | ||
| assert "api_key: [REDACTED]" in captured.out | ||
| assert "mock_token_string" not in captured.out | ||
| assert "session_key=[REDACTED]" in captured.err | ||
| assert "mock_session_value" not in captured.err | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| """Regression tests for sandboxed web-E2E log redaction.""" | ||
|
|
||
| from scripts.ci import sandboxed_web_e2e | ||
|
|
||
|
|
||
| def _api_key_fixture() -> str: | ||
| """Return a representative key/value secret fixture.""" | ||
| return "api_key: " + "mock_token_string" | ||
|
|
||
|
|
||
| def _session_key_fixture() -> str: | ||
| """Return a scanner-safe sensitive assignment fixture.""" | ||
| return "session_key=" + "mock_session_value" | ||
|
|
||
|
|
||
| def _password_fixture() -> str: | ||
| """Return a scanner-safe password assignment fixture.""" | ||
| return "password=" + "mock_password_value" | ||
|
|
||
|
|
||
| def test_emit_result_redacts_payload_fields(capsys, tmp_path) -> None: | ||
| """Machine-readable web evidence redacts commands and paths.""" | ||
| api_key = _api_key_fixture() | ||
| session_key = _session_key_fixture() | ||
| password = _password_fixture() | ||
|
|
||
| class FakeArgs: | ||
| backend_cmd = f"echo {api_key}" | ||
| frontend_cmd = f"echo {session_key}" | ||
| e2e_cmd = f"echo {password}" | ||
| allow_env: list[str] = [] | ||
| evidence_note = "used nothing_sensitive" | ||
| network = "default" | ||
| keep_sandbox = True | ||
|
|
||
|
|
||
| sandboxed_web_e2e.emit_result( | ||
| args=FakeArgs(), | ||
| copied_repo=tmp_path / session_key, | ||
| sandbox_root=tmp_path / "sandbox_test_root", | ||
| backend_ready=True, | ||
| frontend_ready=True, | ||
| exit_code=0, | ||
|
|
||
| elapsed_seconds=1.0, | ||
| ) | ||
| captured = capsys.readouterr() | ||
| assert "[REDACTED]" in captured.out | ||
| assert "mock_token_string" not in captured.out | ||
| assert "mock_session_value" not in captured.out | ||
| assert "mock_password_value" not in captured.out | ||
| assert "sandbox_test_root" in captured.out | ||
|
|
||
|
|
||
| def test_main_redacts_stdout_stderr_and_log_tail(tmp_path, capsys) -> None: | ||
| """Web-E2E subprocess streams and service log tails are redacted.""" | ||
| repo = tmp_path / "repo" | ||
|
|
||
| repo.mkdir() | ||
| api_key = _api_key_fixture() | ||
| session_key = _session_key_fixture() | ||
| password = _password_fixture() | ||
|
|
||
| _ = sandboxed_web_e2e.main( | ||
| [ | ||
| "--repo-root", | ||
| str(repo), | ||
| "--backend-cmd", | ||
| f"python -c \"import sys; print({api_key!r})\"", | ||
| "--frontend-cmd", | ||
| f"python -c \"print({session_key!r})\"", | ||
| "--e2e-cmd", | ||
| ( | ||
| "python -c \"import sys; " | ||
| f"print({api_key!r}); " | ||
| f"print({password!r}, file=sys.stderr)\"" | ||
| ), | ||
| "--startup-timeout", | ||
| "1", | ||
| "--e2e-timeout", | ||
| "5", | ||
| ] | ||
| ) | ||
| captured = capsys.readouterr() | ||
| assert "[REDACTED]" in captured.out | ||
| assert "mock_token_string" not in captured.out | ||
| assert "mock_session_value" not in captured.out | ||
| assert "mock_password_value" not in captured.err | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.