Skip to content

Security hardening: shell injection, Nginx proxy, download integrity, Avalanchego binding#99

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/harden-nginx-proxy-security
Draft

Security hardening: shell injection, Nginx proxy, download integrity, Avalanchego binding#99
Copilot wants to merge 2 commits intomainfrom
copilot/harden-nginx-proxy-security

Conversation

Copy link
Copy Markdown

Copilot AI commented Feb 28, 2026

Four high-severity security issues across API scripts, Nginx configs, download scripts, and Avalanchego configuration docs.

Shell injection in API scripts

Replaced unsafe $1 string interpolation in curl JSON payloads with jq -n --arg across all six affected scripts:

# Before (vulnerable)
curl -X POST --data "{\"params\":{\"blockchainID\":\"${BLOCKCHAIN_ID}\"}}" ...

# After (safe)
curl -X POST --data "$(jq -n --arg id "${BLOCKCHAIN_ID}" \
    '{"jsonrpc":"2.0","method":"platform.getBlockchainStatus","params":{"blockchainID":$id},"id":1}')" ...

Input validation for subnet-cli scripts

Added allowlist regex validation on $1 before passing to CLI tools; quoted all variable interpolations:

  • VM names: ^[a-zA-Z0-9_-]+$
  • Blockchain IDs: ^[a-km-zA-HJ-NP-Z1-9]+$ (base58)

Download integrity verification

Added EXPECTED_SHA256 variable and sha256sum -c - verification to all four install/update scripts. Script aborts on mismatch; warns if the variable is left empty (backward-compatible).

if ! echo "${EXPECTED_SHA256}  ${DOWNLOAD_PATH}" | sha256sum -c -; then
    echo "Error: checksum verification failed. Aborting." >&2
    exit 1
fi

Nginx proxy hardening (rpc/testnet, faucet)

  • Rate limiting: limit_req_zone + limit_req (10 r/s RPC, 5 r/s faucet)
  • Security headers: X-Frame-Options, X-Content-Type-Options, Content-Security-Policy, HSTS
  • client_max_body_size 1m
  • proxy_set_header X-Real-IP and X-Forwarded-For on all proxy locations
  • Default port-80 server now redirects to HTTPS instead of serving content

Avalanchego host binding (README)

Changed all example invocations from --http-host=0.0.0.0 --http-allowed-hosts="*" to --http-host=127.0.0.1 --http-allowed-hosts="localhost,127.0.0.1,<rpc-hostname>", with a note to front with a reverse proxy.

Original prompt

This section details on the original issue you should resolve

<issue_title>[Security][High] Nginx proxy hardening, shell injection in API scripts, and download integrity verification</issue_title>
<issue_description>## Summary

Four high-severity security findings affecting infrastructure configuration and operational scripts:

1. Nginx RPC Proxy Missing Rate Limiting and Security Headers

The public-facing Nginx configs for RPC and faucet reverse proxies lack critical security controls.

Files: rpc/testnet/etc/nginx/sites-available/default, faucet/default

Missing controls:

  • No rate limiting (limit_req_zone / limit_req) — enables DoS attacks
  • No security headers (X-Frame-Options, CSP, HSTS, X-Content-Type-Options)
  • No request body size limit (client_max_body_size)
  • No RPC method filtering — all JSON-RPC methods proxied through
  • Missing proxy_set_header X-Real-IP and X-Forwarded-For
  • Default server on port 80 not redirecting to HTTPS

2. Shell Injection via Unsanitized Arguments in API Scripts

Multiple shell scripts accept $1 and inject it directly into curl JSON payloads via string interpolation without validation.

Files: api/platform.getBlockchainStatus.sh, api/platform.getCurrentValidators.sh, api/platform.validates.sh, api/platform.validatedBy.sh, api/platform.getValidatorsAt.sh, api/info.isBootstrapped.sh, subnet-cli/subnet-cli-create-vmid.sh, subnet-cli/subnet-cli-status-blockchain.sh

Suggested fix: Use jq to safely construct JSON payloads: jq -n --arg id "$1" '{"jsonrpc":"2.0","method":"...","params":{"blockchainID":$id},"id":1}'

3. Download Scripts Lack Integrity Verification

All download scripts fetch binaries from GitHub without verifying checksums or signatures before extracting and executing.

Files: subnet-cli/install-subnet-cli.sh, chains/install-subnet-cli.sh, chains/update-validator-mainnet.sh, chains/update-validator-testnet.sh

Note: sha256sum on line 28 of update scripts only displays hashes, does not verify against known-good values.

Suggested fix: Pin expected SHA256 checksums and verify after download: echo "expected_hash ${DOWNLOAD_PATH}" | sha256sum -c -

4. Avalanchego Configured to Accept Connections from All Hosts

README prescribes --http-host=0.0.0.0 --http-allowed-hosts="*" as standard configuration, exposing raw avalanchego API to the internet.

Suggested fix: Bind to 127.0.0.1, use specific hostnames in --http-allowed-hosts, expose only needed paths via Nginx.

🤖 Generated with Claude Code</issue_description>

Comments on the Issue (you are @copilot in this section)


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

…tegrity, Avalanchego host binding

Co-authored-by: numbers-official <181934381+numbers-official@users.noreply.github.com>
Copilot AI changed the title [WIP] Harden Nginx proxy security configurations for API Security hardening: shell injection, Nginx proxy, download integrity, Avalanchego binding Feb 28, 2026
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.

[Security][High] Nginx proxy hardening, shell injection in API scripts, and download integrity verification

2 participants