Skip to content

DXP-666: Reject mocked validators in eth_sendRawTransaction on hosted studio - #1832

Draft
jmlago wants to merge 2 commits into
v0.124-devfrom
legatus/dxp-666
Draft

jmlago wants to merge 2 commits into
v0.124-devfrom
legatus/dxp-666

Conversation

@jmlago

@jmlago jmlago commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

Fixes DXP-666

What

  • Added a guard to eth_sendRawTransaction (send_raw_transaction in backend/protocol_rpc/endpoints.py). When VITE_IS_HOSTED=true, it rejects any sim_config whose validators have a non-empty plugin_config.mock_response or plugin_config.mock_web_response. The error is JSONRPCError(-32000, "Mocked validators are not allowed in hosted studio").
  • The check runs before anything else, so a rejected request never reaches the DB or consensus.
  • Added @check_forbidden_method_in_hosted_studio to create_validator (sim_createValidator). It was the only validator-changing endpoint without this guard, so on hosted anyone could add a mocked validator to the shared registry. Transactions without sim_config would then run on that validator and pass the new check. It now has the same guard as update_validator, create_random_validators, delete_validator and the others.

Why

On hosted studio, the endpoints that create or update validators and providers already go through check_forbidden_method_in_hosted_studio. One path was still open: eth_sendRawTransaction accepts sim_config.validators. The worker uses those validators to run the persisted transaction (backend/consensus/worker.py, the sim_config.validators snapshot), and validators.Manager forwards their mock entries to GenVM as host data. So anyone could put a transaction on the shared hosted chain that was executed with made-up LLM or web responses.

This replaces the closed #1320 with a narrower fix. That PR blocked sim_config on hosted entirely; this one blocks only mocked validators.

Assumptions

  • Only persisted transactions are blocked. gen_call / sim_call with mocked sim_config validators still work on hosted. They are read-only simulations that don't change shared state, and SDK/gltest mocking relies on them.
  • Non-mocked sim_config stays allowed on hosted, for example custom real validators or genvm_datetime. Only mocks are rejected, unlike fix: dont allow sim_config param in eth_sendRawTransaction endpoint #1320, which blocked all sim_config.
  • What counts as "mocked" is the same rule validators.Manager uses to forward mocks: a key that is present and non-empty. An empty {} mock is a no-op, so it is allowed.
  • sim_createValidator is blocked entirely on hosted without an admin key, not only when the validator has mocks. This matches its sibling endpoints and the hosted frontend, which already hides validator editing (canUpdateValidators in frontend/src/hooks/useConfig.ts). With ADMIN_API_KEY set, the endpoint now requires admin_key, like its siblings.
  • Hosted detection reuses the existing VITE_IS_HOSTED == "true" convention. The error code is -32000, the same as fix: dont allow sim_config param in eth_sendRawTransaction endpoint #1320. Having ADMIN_API_KEY does not bypass the guard.

Testing done

  • New tests/unit/test_send_raw_transaction_hosted_mocks.py (15 cases): detection of LLM and web mocks, malformed input, rejection on hosted, and normal flow for non-hosted, unmocked and no-sim_config requests, plus a regression test that hosted create_validator with mock_response is rejected before any account or registry write.
  • pytest tests/unit -n auto on Python 3.12 with backend/requirements.txt: 1033 passed, 1 skipped.
  • ruff check and black 24.4.2 pass.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Hosted Studio now rejects transaction submissions when the simulation configuration includes a validator with an enabled LLM or web mock response. These requests are stopped before transaction processing and return an error. Submissions with configurations that do not include these mock responses continue as before, and this validation does not affect submissions outside hosted Studio.

@github-actions
github-actions Bot changed the base branch from main to v0.123-dev November 18, 2026 17:42
@github-actions

Copy link
Copy Markdown
Contributor

This PR targeted main, which is only the default/static branch.

I retargeted it to v0.123-dev, the active development branch. Pushes to v0.123-dev automatically fast-forward main.

@coderabbitai

coderabbitai Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@jmlago

jmlago commented Nov 18, 2026

Copy link
Copy Markdown
Member Author

Legatus audit: Changes requested (commit 8a2e44d)

  • P1 — Hosted mock restriction remains bypassable. backend/protocol_rpc/endpoints.py:2118 checks only transaction-supplied validators, but create_validator at line 552 remains unguarded and publicly exposed through sim_createValidator. I verified that, with VITE_IS_HOSTED=true and no admin key, schema-valid mock_response data reaches the shared registry. Subsequent transactions without sim_config pass the new guard and can use those validators. Protect validator creation in hosted mode and add a regression test covering this path.

Validation: 1,032 unit tests passed, 1 skipped. Full pytest stopped during collection with missing gltest, genlayer_py, and rpc modules. Audit worktree removed; nothing pushed or merged.

@jmlago

jmlago commented Nov 18, 2026

Copy link
Copy Markdown
Member Author

Legatus audit: Approved (commit cea441c)

No blocking findings. The validator-creation bypass is fixed and covered by a regression test. Both mock types are rejected on hosted Studio; local creation still works.

Validation: 1,033 unit tests passed, 1 skipped, with a clean rerun after an initial shutdown segmentation fault. Full pytest remains blocked by collection-time import errors. Audit worktree removed; nothing pushed or merged.

@jmlago

jmlago commented Nov 18, 2026

Copy link
Copy Markdown
Member Author

/run-e2e all

jmlago and others added 2 commits November 18, 2026 17:53
…d studio

Fixes DXP-666

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
create_validator was the only validator-mutating endpoint without the
hosted guard, letting callers register mocked validators in the shared
registry and bypass the eth_sendRawTransaction sim_config check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jmlago

jmlago commented Nov 18, 2026

Copy link
Copy Markdown
Member Author

Legatus audit: Approved (commit 0f5d19f)

No blocking findings. The rebased guard rejects mocked transaction validators before admission side effects, and validator creation remains protected.

Validation: 1,903 unit tests passed, 7 skipped. Full pytest stopped during collection due to missing backend, genlayer_py, and rpc imports. Audit worktree removed; nothing pushed or merged.

@jmlago

jmlago commented Nov 18, 2026

Copy link
Copy Markdown
Member Author

/run-e2e all

@ci-core-e2e-runner

Copy link
Copy Markdown
Contributor

E2E status was updated. Follow the current E2E and merge checks on this PR. Detailed diagnostics are available internally.

@jmlago

jmlago commented Nov 18, 2026

Copy link
Copy Markdown
Member Author

Legatus audit: Approved (commit 0f5d19f)

No blocking findings. The head and diff are unchanged from the previous review.

Fresh validation: 1,903 unit tests passed, 7 skipped. Full pytest remains blocked during collection by backend, genlayer_py, and rpc import errors. Audit worktree removed; nothing pushed or merged.

@jmlago

jmlago commented Nov 18, 2026

Copy link
Copy Markdown
Member Author

/run-e2e all

@ci-core-e2e-runner

Copy link
Copy Markdown
Contributor

E2E status was updated. Follow the current E2E and merge checks on this PR. Detailed diagnostics are available internally.

@danieljrc888
danieljrc888 marked this pull request as draft November 18, 2026 21:39
@danieljrc888
danieljrc888 changed the base branch from v0.123-dev to v0.124-dev November 18, 2026 23:34

@danieljrc888 danieljrc888 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed at 0f5d19f. The guard is correct for what it detects and is low risk, but it does not deliver the outcome the ticket names (no persisted transaction on a hosted Studio executed by validators the sender controls).

1. The check is a denylist of two keys; the sender still controls the validators

_sim_config_has_mocked_validators (backend/protocol_rpc/endpoints.py) only looks for mock_response / mock_web_response in plugin_config. A sim_config.validators entry that supplies its own config, plugin and plugin_config is still accepted: the worker builds a virtual validator from it (backend/consensus/worker.py, the LLMProvider(...) branch when all three are present) and validate_provider accepts it. The transaction is persisted and executed by a provider configuration chosen by the sender, which is the same result as a mock through a different field.

Fix: on hosted, turn this into an allowlist for persisted transactions. Either reject any sim_config.validators entry that carries explicit config / plugin / plugin_config (so only get_default_provider_for(provider, model) is reachable), or reject sim_config.validators entirely on hosted and keep only genvm_datetime. Add tests for the custom provider case, not only for the two mock keys.

2. Smaller

  • False positive: a validator with a mock key but config / plugin null is rejected although the worker would ignore its plugin_config and fall back to the default provider. An allowlist removes this case.
  • The description says this PR adds the hosted guard on sim_createValidator. That guard is already in the base (it came with #1801); the second commit only adds a test for it. Please correct the description.
  • The red "E2E Tests" run is not caused by this PR (the plan job crashed while resolving the matrix, nothing was built), and it ran against the old base before the retarget. It needs a rerun on v0.124-dev.

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.

2 participants