Skip to content

fix: conservative trust-boundary hardening (#540) - #551

Open
Shashankss1205 wants to merge 1 commit into
mainfrom
fix/540-security-hardening
Open

fix: conservative trust-boundary hardening (#540)#551
Shashankss1205 wants to merge 1 commit into
mainfrom
fix/540-security-hardening

Conversation

@Shashankss1205

Copy link
Copy Markdown
Collaborator

Addresses #540 — the conservative, non-controversial parts of the trust-boundary umbrella.

Scope note

BUG-09 (sandboxing instantiate/craft) is intentionally left out. The server already exposes run_command (arbitrary host execution by design), so the caller is nominally trusted; locking down craft specs with an AST allowlist risks breaking legitimate composites and is a posture decision for the maintainers. This PR does the parts that are pure improvements regardless of posture.

BUG-11 — call_method exposed private/dunder methods

call_method(method_name="__reduce__") returned the full __dict__, dumping the fitted _y/_X training data to any caller. call_method now rejects any method_name starting with _, except a small allowlist (__call__ for callable metrics/aligners, __len__, __repr__, __str__). Public methods are unaffected.

BUG-10 — instantiate accepted non-estimators

instantiate("42") → an est_ handle of type int that failed confusingly downstream. After craft, the result must be an sktime object (skbase BaseObject, or duck-typed get_params + get_class_tag); otherwise a clear "Spec did not produce an sktime estimator, got int".

BUG-12 — run_command description was false

It claimed the command runs "inside the sktime container". Corrected to say it runs on the host, in the server's working directory, as the server user.

BUG-23 — run_command output was unbounded

seq 1 100000 returned ~689k chars. Output is capped at ~20k chars (head+tail) with a truncated flag, and a non-zero exit now includes an "error" key like every other tool (also closes N-24).

Testing

  • New tests/test_security_hardening.py (14 tests): __reduce__/__class__/private methods blocked, public methods work; 42/[1,2,3]/None rejected, real estimator still instantiates; large output truncated, small output intact, non-zero exit has error.
  • Full suite: 303 passed.

🤖 Generated with Claude Code

Non-controversial parts of the trust-boundary issue (instantiate sandboxing,
BUG-09, is intentionally left for a maintainer decision — the server already
exposes run_command):

- BUG-11: call_method now blocks private/dunder methods (allowlist of __call__,
  __len__, __repr__, __str__). __reduce__ previously dumped __dict__ including
  the fitted _y/_X training data to any caller.
- BUG-10: instantiate rejects specs that don't produce an sktime object
  ("42" -> int, "[1,2,3]" -> list); they used to get est_ handles that failed
  confusingly downstream.
- BUG-12: corrected run_command's description — it runs on the HOST as the
  server user, not "inside the sktime container".
- BUG-23: run_command output is capped (~20k chars) with a truncated flag, and
  a non-zero exit now includes an "error" key like every other tool.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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