Skip to content

[BUG] AuditGuardContract::verify_context performs no real verification - trusts a caller-supplied boolean #188

Description

@N-thnI

Priority: High

Description

src/audit-guard/ is a real Cargo workspace member (Cargo.toml:2, members = ["engine-core", "src/audit-guard"]) whose doc comments claim it verifies security context against "formal verification checks." In reality verify_context just checks the caller's own supplied is_verified: bool and returns Ok if true — no real verification, no state lookup, no cryptography. validate_and_audit accepts a _signature: BytesN<64> that is never read, with a comment literally reading // Mock implementation for the issue; its only check is payload.len() == 0.

Location

src/audit-guard/src/lib.rs:26-35 (verify_context), :39-49 (validate_and_audit)

Current Behavior

pub fn verify_context(_env: Env, author: Address, is_verified: bool) -> Result<(), AuditGuardError> {
    author.require_auth();
    if !is_verified { return Err(AuditGuardError::VerificationFailed); }
    Ok(())
}
pub fn validate_and_audit(_env: Env, payload: BytesN<32>, _signature: BytesN<64>) -> Result<(), AuditGuardError> {
    if payload.len() == 0 { return Err(AuditGuardError::InvalidPayload); }
    // Mock implementation for the issue
    Ok(())
}

Expected Behavior

Functions named/documented as performing formal verification and signature validation should actually verify a signature over the payload (e.g. via env.crypto()) rather than trust a caller-supplied flag or ignore the signature entirely.

Repro / Evidence

verify_context(env, my_address, true)                          // always succeeds
validate_and_audit(env, any_nonzero_payload, garbage_signature) // always succeeds -- signature ignored

Zero #[test] functions exist in this file.

Impact

If ever wired up as a real audit gate (as its name/docs imply), it provides zero security value while looking like a verification layer — a classic security-theater vulnerability. Even unintegrated today (confirmed via grep — no references from engine-core), it's a compiled, deployable workspace member with misleading documentation.

Suggested Fix

Implement genuine signature verification against payload, remove the trust-the-caller is_verified pattern, or explicitly mark the module unimplemented!()/excluded from release builds until real logic lands.

Acceptance Criteria

  • AC-1: verify_context derives its result from actual state, not a caller-supplied bool.
  • AC-2: validate_and_audit actually verifies _signature against payload, or is clearly marked unimplemented.
  • AC-3: Unit tests proving a forged/invalid signature is rejected (currently zero tests exist).

Definition of Done

  • Fix merged with all AC items checked
  • Regression test passes in CI

Metadata

Metadata

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial Campaign | FWC26Campaign: Official Campaign | FWC26Third CampaignCampaign: Third CampaignbugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions