Skip to main content

Semantic security scanner for Algorand smart contracts and workflows

Project description

AlgoSec (A Secure)

AlgoSec is a semantic security scanner and runtime decision assistant for Algorand smart contracts.

It supports static contract analysis, on-chain checks, AI-assisted risk narratives, contract auto-remediation, and API-based policy gating.

1) What AlgoSec does today

Contract scanning (TEAL + PyTeal)

  • Scans files or folders containing .teal / .py contracts.
  • Normalizes PyTeal patterns (approval_program / clear_state_program) before analysis.
  • Runs semantic checks for common exploit paths:
    • missing RekeyTo == ZeroAddress
    • missing CloseRemainderTo == ZeroAddress
    • missing AssetCloseTo == ZeroAddress
    • unguarded update/delete/admin paths
    • unsafe Gtxn assumptions without strict group validation
    • missing argument-bound checks
    • state mutation without sender/role authorization

Scoring and risk output

  • Computes security_score, risk_score, grade, and deploy verdict.
  • Exit code is non-zero when findings/errors exist (CI-friendly behavior).

Reports

  • Console dashboard (visual)
  • JSON
  • Markdown
  • SARIF
  • HTML (expanded analytics + charts)

On-chain and indexer analysis

  • Scan deployed app by app_id
  • Scan account risk posture
  • Scan ASA metadata/configuration
  • Scan transaction streams for anomalies

AI-assisted workflow

  • ai-run: scan + simulate + policy decision + explanation artifacts.
  • Works in two modes:
    • deterministic mode (always available; no key required)
    • Gemini narrative mode (optional; enabled when API key is available)

Auto-fix workflow

  • fix-contract applies hardened guard patterns to vulnerable PyTeal contracts.
  • Optional post-fix verification scan (--verify).

Entitlement / premium support

  • premium-status supports ASA-balance mode and subscription-app mode.
  • Testnet deploy commands are dry-run by default for safety.

2) Installation

Standard install

pip install algo-secure

With Gemini SDKs

pip install "algo-secure[ai]"

Development install

pip install -e .

3) Quick start

# Home UI
algosec

# Core scan
algosec analyze ./contracts

# Export html report
algosec scan ./contracts -f html -o report.html

# Compare two versions
algosec diff ./contracts_old ./contracts_new

# Auto-fix a vulnerable contract
algosec fix-contract examples/incoming_contracts/random_user_contract.py --verify

Aliases: algosec, alg, aplussec.

4) Command groups

Static and project scan

  • scan, alg_scan, analyze
  • stats
  • diff

On-chain/indexer scan

  • scan-deployed-app, alg_scan_deployed_app
  • scan-account, alg_scan_account
  • scan-asset, alg_scan_asset
  • scan-transactions, alg_scan_transactions

Testing

  • test-pyteal, alg_test_pyteal

AI and remediation

  • ai-status
  • ai-run, alg_ai_run
  • fix-contract, alg_fix_contract

Entitlement and deploy

  • premium-status
  • deploy-token-registry-testnet
  • deploy-subscription-testnet

API server

  • serve

5) AI behavior (important)

AlgoSec is designed to work on any system even without LLM credentials.

  • If no Gemini key/sdk is available, ai-run still executes using deterministic reasoning (narrative_provider=deterministic).
  • If Gemini is available, narrative generation switches to narrative_provider=gemini.

Gemini key lookup order:

  1. ALGOSEC_GEMINI_API_KEY
  2. GEMINI_API_KEY
  3. GOOGLE_API_KEY

Optional one-shot override:

algosec ai-status --gemini-api-key "<key>"

6) Security and secret handling

  • No API key is hardcoded in source.
  • Auth signing secret does not default to a fixed insecure string.
  • If ALGOSEC_AUTH_SECRET is absent, runtime uses an ephemeral in-memory secret.
  • Recommendation for production API deployments:
    • set ALGOSEC_AUTH_SECRET
    • set ALGOSEC_REQUIRE_API_KEY=1
    • set ALGOSEC_API_KEY

7) API surface

Primary routes include:

  • /health
  • /scan
  • /simulate
  • /safe_execute
  • /agent/run
  • /auth/challenge
  • /auth/verify
  • /auth/me

8) Packaging and release status

  • pyproject.toml is configured for setuptools build.
  • Wheel + sdist build is validated (python -m build, twine check).
  • PyPI publishing workflow is present in .github/workflows/release.yml.

9) License

MIT — see LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

algo_secure-0.1.2.tar.gz (70.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

algo_secure-0.1.2-py3-none-any.whl (97.9 kB view details)

Uploaded Python 3

File details

Details for the file algo_secure-0.1.2.tar.gz.

File metadata

  • Download URL: algo_secure-0.1.2.tar.gz
  • Upload date:
  • Size: 70.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for algo_secure-0.1.2.tar.gz
Algorithm Hash digest
SHA256 f8117ebdc74ce4dc34cfa3b0cef4ef05bf2845f43651af54d7dac49d5b4692c5
MD5 f5d05bc2cfe43695f6f7b85f16bafb84
BLAKE2b-256 d0e475063f7745ffefe10a1b93db535af75fd46b20d0b2e954de40d05166f2de

See more details on using hashes here.

File details

Details for the file algo_secure-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: algo_secure-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 97.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for algo_secure-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f6040ce392a4bdf6f565ab46e73d9b0dbbe55afc13057307add76404c837f673
MD5 0caa62095eb8c61e27cc853ebd9169d9
BLAKE2b-256 f3e26bf21f30216b421e73f30c1d0479c68107022fea6be76720fa5ea38f4be1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page