Skip to content

Commit 12a468a

Browse files
Merge pull request #764 from devpeter999/fix/devpeter999-description-cancelledpolicy-oraclezero-categoryname
fix: validate proposal description, cancelled policy claim, oracle non-zero address, and category name
2 parents 7bd2544 + 4c2206f commit 12a468a

4 files changed

Lines changed: 29 additions & 7 deletions

File tree

‎contracts/claims-processor/src/lib.rs‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,10 @@ impl ClaimsProcessor {
546546
if policy.policyholder != *claimant {
547547
panic_with_error!(env, Error::Unauthorized);
548548
}
549+
// Guard: reject claims for cancelled policies (issue #731).
550+
if policy.status == parashield_policy_engine::PolicyStatus::Cancelled {
551+
panic_with_error!(env, Error::PolicyNotActive);
552+
}
549553
if policy.status != parashield_policy_engine::PolicyStatus::Active {
550554
panic_with_error!(env, Error::PolicyNotActive);
551555
}

‎contracts/governance-dao/src/lib.rs‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -325,11 +325,10 @@ impl GovernanceDao {
325325
panic_with_error!(&env, Error::TitleTooLong);
326326
}
327327

328-
// SECURITY FIX: Validate impact analysis length to prevent storage exhaustion.
329-
// Limit to 4096 bytes — reasonable for a proposal description without enabling
330-
// attacks that reserve huge storage or inflate transaction costs.
331-
if impact_analysis.is_empty() {
332-
panic_with_error!(&env, Error::InvalidInput);
328+
// SECURITY FIX: Validate proposal description (impact_analysis) is not empty (issue #732).
329+
// Enforce non-empty and minimum length to ensure informative proposals, bounded up to 4096 bytes.
330+
if impact_analysis.is_empty() || impact_analysis.len() < 5 {
331+
panic_with_error!(&env, Error::EmptyDescription);
333332
}
334333
if impact_analysis.len() > 4096 {
335334
panic_with_error!(&env, Error::InvalidInput);
@@ -1905,6 +1904,10 @@ impl GovernanceDao {
19051904
) {
19061905
Self::require_admin(&env, &admin);
19071906

1907+
if description.is_empty() {
1908+
panic_with_error!(&env, Error::EmptyDescription);
1909+
}
1910+
19081911
if env.storage().instance().has(&StorageKey::Template(name.clone())) {
19091912
panic_with_error!(&env, Error::DuplicateTemplateName);
19101913
}

‎contracts/policy-engine/src/lib.rs‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,8 @@ impl PolicyEngine {
218218
if oracle_buf[0] != b'C' {
219219
panic_with_error!(&env, Error::InvalidAddress);
220220
}
221+
// Reject zero address as oracle (issue #730)
222+
Self::require_not_zero_address(&env, &oracle_address);
221223

222224
let balance_res = env.try_invoke_contract::<i128, soroban_sdk::Error>(
223225
&usdc_token,
@@ -367,6 +369,8 @@ impl PolicyEngine {
367369
if oracle_buf[0] != b'C' {
368370
panic_with_error!(&env, Error::InvalidAddress);
369371
}
372+
// Reject zero address as oracle (issue #730)
373+
Self::require_not_zero_address(&env, &new_oracle);
370374

371375
let change = PendingOracleChange {
372376
new_oracle: new_oracle.clone(),
@@ -2002,6 +2006,17 @@ impl PolicyEngine {
20022006
}
20032007

20042008
fn migrate_v2_to_v3(_env: &Env) {}
2009+
2010+
/// Require that an address is not the zero address (issue #730).
2011+
fn require_not_zero_address(env: &Env, address: &Address) {
2012+
let zero = Address::from_string(&soroban_sdk::String::from_str(
2013+
env,
2014+
"GAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAWHF",
2015+
));
2016+
if *address == zero {
2017+
panic_with_error!(env, Error::InvalidAddress);
2018+
}
2019+
}
20052020
}
20062021

20072022
#[cfg(test)]

‎contracts/risk-pool/src/lib.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,8 +283,8 @@ impl RiskPool {
283283
if env.storage().instance().has(&StorageKey::Initialized) {
284284
panic_with_error!(&env, Error::AlreadyInitialized);
285285
}
286-
// An empty category would make the pool's accounting and LP NFT
287-
// metadata ambiguous, so reject it up front (issue #520).
286+
// Category name cannot be empty and must describe a valid risk category (issue #729, #520).
287+
// Empty category names are rejected to prevent unnamed categories in the pool registry.
288288
if category == Symbol::new(&env, "") {
289289
panic_with_error!(&env, Error::InvalidCategory);
290290
}

0 commit comments

Comments
 (0)