- Category: authentication
- Severity: Critical
- Rule name:
auth_gap
S001 flags any public function inside an impl block that performs a privileged operation without first calling require_auth() or require_auth_for_args(). Privileged operations are:
- Storage mutation —
.set(),.update(),.remove(), or.extend_ttl()onstorage().persistent(),temporary(), orinstance(). - External contract call —
.invoke_contract(), or a method call on a receiver whose type name ends inClient/_client.
Reserved Soroban entry-points (__constructor, __check_auth) are excluded automatically. Private (fn) functions and functions outside impl blocks are not checked.
A public function that writes state or calls external contracts without checking the caller's identity can be invoked by anyone — draining balances, replacing the admin, or triggering arbitrary cross-contract logic. This is one of the most common critical findings in Soroban audits: if require_auth is missing, anyone can drain your contract.
#![no_std]
use soroban_sdk::{contract, contractimpl, contracttype, Address, Env};
#[contracttype]
pub enum DataKey {
Admin,
}
#[contract]
pub struct Token;
#[contractimpl]
impl Token {
// S001: anyone can replace the admin — no auth guard.
pub fn set_admin(env: Env, new_admin: Address) {
env.storage().instance().set(&DataKey::Admin, &new_admin);
}
}#![no_std]
use soroban_sdk::{contract, contractimpl, contracttype, Address, Env};
#[contracttype]
pub enum DataKey {
Admin,
}
#[contract]
pub struct Token;
#[contractimpl]
impl Token {
pub fn set_admin(env: Env, new_admin: Address) {
// Guard added: the current admin must authorize the change.
let admin: Address = env.storage().instance().get(&DataKey::Admin).unwrap();
admin.require_auth();
env.storage().instance().set(&DataKey::Admin, &new_admin);
}
}- Vector:
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H - Base score: 9.8
- Rating: Critical
An unauthenticated network attacker can fully compromise integrity and availability (and confidentiality of controlled assets) with a single low-complexity transaction.
- Call
addr.require_auth()(oraddr.require_auth_for_args(...)) as the first statement in every state-mutating or external-call public function. - Authorize the correct principal — typically the current admin for privileged operations, or the
fromaddress for value transfers. - Consider whether read-only functions that expose sensitive data also need authentication.
- Re-run
sanctifierto confirm the finding clears.