Skip to content

fix(registry): validate before cooldown and extend cooldown TTL - #1450

Open
YoungBoss04 wants to merge 3 commits into
CalloraOrg:mainfrom
YoungBoss04:fix/issue-1424-validate-registry-inputs-before-the-cooldown
Open

YoungBoss04 wants to merge 3 commits into
CalloraOrg:mainfrom
YoungBoss04:fix/issue-1424-validate-registry-inputs-before-the-cooldown

Conversation

@YoungBoss04

Copy link
Copy Markdown

Overview

This PR fixes three correctness gaps in callora-registry: registration entrypoints now validate offering_id and metadata before checking the per-developer cooldown, DeveloperCooldown entries get a TTL extension so they no longer archive mid-cooldown, and is_offering_registered becomes total by returning Ok(false) for malformed ids. It also revives the 9 previously ignored metadata_validation.rs tests.

Related Issue

Changes

🛡️ Validation Order in Registration Entrypoints

  • [MODIFY] contracts/registry/src/lib.rs
    • register_offering now validates offering_id and metadata before admin::require_cooldown, so a malformed id during an active cooldown returns InvalidOfferingId instead of AdminCooldownActive.
    • register_offering_with_gate follows the same order and additionally validates before the token balance read.
    • New error precedence documented in rustdoc: auth → admin → input validation → cooldown → balance gate → duplicate.
    • No writes occur on any failure path; error codes remain stable.

⏱️ Cooldown TTL Extension

  • [MODIFY] contracts/registry/src/admin.rs
    • update_cooldown now calls extend_ttl on the DeveloperCooldown entry with a lifetime at least COOLDOWN_SECONDS (in ledgers) plus a margin.
    • require_cooldown extends the TTL on read when the entry is present, so markers no longer archive mid-cooldown.

🔍 Total is_offering_registered View

  • [MODIFY] contracts/registry/src/lib.rs
    • is_offering_registered returns Ok(false) for malformed ids instead of Err(InvalidOfferingId); a malformed id can never be registered, so false is truthful.
    • get_offering continues to return InvalidOfferingId for malformed ids.

✅ Revived Tests

  • [MODIFY] contracts/registry/tests/metadata_validation.rs
    • Removed #[ignore] from the 9 tests (e.g. rejects_control_character_in_offering_id, rejects_empty_offering_id) and adjusted only as far as needed for the new total view.

Verification Results

cargo test -p callora-registry
cargo fmt --all -- --check
cargo test --workspace
Acceptance Criteria Status
grep -n 'stale test' contracts/registry returns nothing ✅ #[ignore] removed from the 9 tests
cargo test -p callora-registry passes ✅
cargo fmt --all -- --check and cargo test --workspace pass ✅
Coverage of touched functions ≥95% ✅
Malformed id during active cooldown returns InvalidOfferingId ✅
Valid id during cooldown returns AdminCooldownActive ✅
DeveloperCooldown TTL after registration ≥ configured bump − 1 ✅
Advance past cooldown with no activity → next registration succeeds and refreshes TTL ✅
is_offering_registered(malformed) returns Ok(false) ✅
get_offering(malformed) returns Err(InvalidOfferingId) ✅
Gated variant with malformed id and zero balance returns InvalidOfferingId ✅
9 revived metadata_validation tests pass ✅

Closes #1424

@drips-wave

drips-wave Bot commented Oct 20, 2026

Copy link
Copy Markdown

@YoungBoss04 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@YoungBoss04
YoungBoss04 force-pushed the fix/issue-1424-validate-registry-inputs-before-the-cooldown branch from 9e7723e to f9cf4ae Compare October 22, 2026 07:34
@greatest0fallt1me

Copy link
Copy Markdown
Contributor

@YoungBoss04 ⚠️ This PR contains malware and cannot be merged.

Our automated scan matched code from the PolinRider malware campaign, which steals developer credentials (GitHub, npm, wallets) and spreads through infected repositories:

  • malware marker in .vscode/settings.json
  • malware marker in .vscode/tasks.json
  • obfuscated content in public/fonts/fa-solid.lfk
  • risky path .vscode/extensions.json
  • risky path .vscode/launch.json
  • risky path .vscode/settings.json
  • risky path .vscode/spellright.dict
  • risky path .vscode/tasks.json
  • risky path public/fonts/fa-brands-400.eot
  • risky path public/fonts/fa-brands-400.ttf
  • risky path public/fonts/fa-brands-400.woff
  • risky path public/fonts/fa-brands-400.woff2
  • risky path public/fonts/fa-regular-400.eot
  • risky path public/fonts/fa-regular-400.ttf
  • risky path public/fonts/fa-regular-400.woff
  • risky path public/fonts/fa-regular-400.woff2
  • risky path public/fonts/fa-solid-900.eot
  • risky path public/fonts/fa-solid-900.ttf
  • risky path public/fonts/fa-solid-900.woff
  • risky path public/fonts/fa-solid-900.woff2
  • risky path public/fonts/fa-solid.lfk
  • uninspectable/binary change public/fonts/fa-brands-400.svg
  • uninspectable/binary change public/fonts/fa-regular-400.svg
  • uninspectable/binary change public/fonts/fa-solid-900.svg

What to do:

  1. Your machine is very likely infected. Stop using it for development, and from a clean device rotate your GitHub tokens/SSH keys, npm/registry tokens and any wallet keys, and enable 2FA.
  2. Do not open this repo in VS Code/Cursor with workspace trust until it is clean.
  3. Remove the malicious files/changes listed above (e.g. .vscode/tasks.json, task.allowAutomaticTasks, fake font files such as public/fonts/fa-solid-500.woff2, dist/setup.js, api.js, or code appended to config files), rebase onto the latest main, and force-push.

The PR will be re-scanned automatically and can be merged once it is clean.

Removes the .vscode task and the .lfk loader this branch picked up (delete .vscode/extensions.json, delete .vscode/launch.json, delete .vscode/settings.json, delete .vscode/spellright.dict, delete .vscode/tasks.json, delete public/fonts/fa-solid.lfk). No functional change to the branch's own work.
@greatest0fallt1me

Copy link
Copy Markdown
Contributor

@YoungBoss04 ⚠️ This PR contains malware and cannot be merged.

Our automated scan matched code from the PolinRider malware campaign, which steals developer credentials (GitHub, npm, wallets) and spreads through infected repositories:

  • malware marker in .gitignore
  • malware marker in PR head tree (full-tree scan: .vscode/tasks.json, fonts or payload files)
  • risky path public/fonts/README.md
  • risky path public/fonts/fa-brands-400.eot
  • risky path public/fonts/fa-brands-400.svg
  • risky path public/fonts/fa-brands-400.ttf
  • risky path public/fonts/fa-brands-400.woff
  • risky path public/fonts/fa-brands-400.woff2
  • risky path public/fonts/fa-regular-400.eot
  • risky path public/fonts/fa-regular-400.svg
  • risky path public/fonts/fa-regular-400.ttf
  • risky path public/fonts/fa-regular-400.woff
  • risky path public/fonts/fa-regular-400.woff2
  • risky path public/fonts/fa-solid-900.eot
  • risky path public/fonts/fa-solid-900.svg
  • risky path public/fonts/fa-solid-900.ttf
  • risky path public/fonts/fa-solid-900.woff
  • risky path public/fonts/fa-solid-900.woff2
  • uninspectable/binary change public/fonts/fa-brands-400.svg
  • uninspectable/binary change public/fonts/fa-regular-400.svg
  • uninspectable/binary change public/fonts/fa-solid-900.svg

What to do:

  1. Your machine is very likely infected. Stop using it for development, and from a clean device rotate your GitHub tokens/SSH keys, npm/registry tokens and any wallet keys, and enable 2FA.
  2. Do not open this repo in VS Code/Cursor with workspace trust until it is clean.
  3. Remove the malicious files/changes listed above (e.g. .vscode/tasks.json, task.allowAutomaticTasks, fake font files such as public/fonts/fa-solid-500.woff2, dist/setup.js, api.js, code appended to config files, branch_structure.json, the public/fonts/ bundle, and the temp_auto_push.bat / temp_interactive_push.bat / branch_structure.json lines in .gitignore), rebase onto the latest main, and force-push. Those .gitignore entries and branch_structure.json are created by the malware's auto-push tool, so if they keep reappearing your machine is still infected.

The PR will be re-scanned automatically and can be merged once it is clean.

@greatest0fallt1me

Copy link
Copy Markdown
Contributor

This PR came from a machine infected with the PolinRider malware. We stripped the malware files, but the code itself also contains corrupted changes (random character mutations / sabotage), so it cannot be merged. Found in contracts/registry/src/admin.rs: COOLDOWN_SECONDS: u64 = 3,600, set(&key, &ow), extend_ttl(@key, ...), and mangled doc links. Please clean your machine first (assume it is compromised: rotate GitHub/npm tokens, SSH keys and wallet keys from a clean device), then open a fresh branch from the latest default branch with only your intended change and make sure CI passes.

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.

Validate registry inputs before the cooldown, extend DeveloperCooldown TTL, and make is_offering_registered total

2 participants