Skip to content

Skip checks for defined appCodes#4118

Open
fafk wants to merge 19 commits intomainfrom
skip-checks-for-defined-apps
Open

Skip checks for defined appCodes#4118
fafk wants to merge 19 commits intomainfrom
skip-checks-for-defined-apps

Conversation

@fafk
Copy link
Contributor

@fafk fafk commented Feb 3, 2026

Description

For the integration with Euler we want to skip balance checks, because the order will get the necessary funds from pre-hooks. This PR adds a new config that allows to define appCode values (from AppData) that we skip these validations for. Signature checks are skipped for all 1271 orders, but kept for others as presign/Eip712 should always be valid independent of prehooks.

Changes

  • Added a new config --filter-bypass-app-data-sources="Euler","FooApp"
  • Added a new type AppCodeBypass that encapsulates the logic that decides which orders should skip balance validations
  • A cache so we don't keep parsing appdata for every auction
  • Nuked disable_1271_order_sig_filter and disable_1271_order_balance_filter config flags - 1271 now just always skips these checks

How to test

Unit tests.

@fafk fafk requested a review from a team as a code owner February 3, 2026 12:04
@fafk fafk marked this pull request as draft February 3, 2026 12:06
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a mechanism to bypass signature and balance checks for orders from specified applications using an appCode. However, the implementation has several security vulnerabilities: it allows regular ECDSA orders to bypass critical security checks, the appCode is user-controlled and can be spoofed, and an unbounded cache could lead to a Denial of Service. Additionally, there is a race condition in the appCode caching logic that can lead to redundant work. It is recommended to restrict the bypass to EIP-1271 orders, verify the app_data hash, and use a bounded cache.

@fafk fafk changed the title Skip checks for defined apps Skip checks for defined appCodes Feb 3, 2026
@fafk fafk force-pushed the skip-checks-for-defined-apps branch from f30e6c2 to 417b044 Compare February 4, 2026 08:46
@fafk fafk requested a review from kaze-cow February 4, 2026 10:47
@fafk fafk force-pushed the skip-checks-for-defined-apps branch from d277f7d to 05c1b38 Compare February 4, 2026 12:38
@fafk fafk marked this pull request as ready for review February 4, 2026 12:38
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds a feature to bypass balance and signature checks for orders from specified appCode sources. However, the current implementation introduces significant security vulnerabilities, including an unauthenticated filter bypass where the user-provided appCode can be easily spoofed, and a potential Denial of Service due to unbounded cache growth that could lead to memory exhaustion. Additionally, the implementation in AppCodeBypass::build_bypass_set contains critical syntax errors where if let is incorrectly combined with a boolean condition using &&, which will cause compilation to fail.

Comment on lines +335 to +338
/// The application code identifying the source of the order (e.g., "CoW
/// Swap", "Barter").
#[serde(rename = "appCode")]
app_code: Option<String>,
Copy link
Contributor

Choose a reason for hiding this comment

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

Since anyone can specify anything here, could this lead to an attack where the balance is not checked for unexpected orders? So the system could be flooded with orders with insufficient balance that only fail during settlement encoding.

Copy link
Contributor Author

@fafk fafk Feb 5, 2026

Choose a reason for hiding this comment

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

The orderbook validates balances, so you can't do that. The issue here is that the autopilot doesn't run prehooks which make sure you have the right balance while orderbook does. In the long run we want to nuke all validations in the autopilot.

Copy link
Contributor

Choose a reason for hiding this comment

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

I am not following, sorry. Are you saying this app code skips the balance validation in the autopilot, but not in the orderbook?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes that's right.

Copy link
Contributor

@squadgazzz squadgazzz Feb 6, 2026

Choose a reason for hiding this comment

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

The orderbook validates balances

I can't find it. Could you point me to this check? The only check I found is the ability of the owner to send at least 1 atom of the token:

/// Verifies that tokens can actually be transferred from the user account
/// to the settlement contract (takes pre-hooks into account).
async fn ensure_token_is_transferable(
&self,
order: &OrderCreation,
owner: Address,
app_data: &OrderAppData,
) -> Result<(), ValidationError> {
let mut res = Ok(());
// Simulate transferring a small token balance into the settlement contract.
// As a spam protection we require that an account must have at least 1 atom
// of the sell_token. However, some tokens (e.g. rebasing tokens) actually run
// into numerical issues with such small amounts. But there are also tokens
// where a single atom is already quite expensive (tokenized stocks).
// To cover both cases we simulate multiple small transfers. As soon as one
// passes we consider the token transferable. If all transfers fail we return
// the last error.
for transfer_amount in [1, 10, 100].into_iter().map(U256::from) {

@fafk fafk force-pushed the skip-checks-for-defined-apps branch from 9b8cc52 to c8eb853 Compare February 5, 2026 13:55
@fafk fafk force-pushed the skip-checks-for-defined-apps branch from e697b05 to 01b0318 Compare February 6, 2026 11:55
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.

3 participants