Skip to content

Usage limits and hosting checks after the 14 Nov security review #327

Closed

Description

@Lexirieru

On 14 Nov a read-only review of the repository and the hosted API (AI-assisted, with Claude Code; not an independent audit) looked for leaked secrets, what the public API gives away, and ways to use up the shared NEAR AI credit or overload the API.

Nothing leaked: no .env file was ever committed (full git history checked), every .env.example holds names only, and the hosted API's answers carry no keys, URLs or stack traces. CSRF, body size, sign-in and the internal routes behaved as documented.

Found, fixed in code (PR to follow from fix/abuse-limits)

  • Run limits for every account. Only try-out users had limits; a wallet sign-in needs just a free testnet account. Now 60 runs an hour and 300 a day per user, and a daily total for all users (RUNS_PER_DAY_GLOBAL, default 3000, 0 = off).
  • Autopilot limits. A job could be scheduled every minute. Now at most every 15 minutes, 5 jobs on per Mind and 10 per owner, 100 scheduled runs a day per owner. At engine start, jobs already on with a faster schedule are paused (not deleted) with pausedFor: too_frequent.
  • POST /v1/auth/challenge: 60 per IP per hour.

Not covered by the review: needs the hosted box and Cloudflare (@Lin1er)

  • Firewall on the box. The per-IP limits read the visitor's address from the header Cloudflare sets, which is only trustworthy if the backend and engine ports cannot be reached except through the tunnel. Please confirm (read-only) which ports listen on which addresses, and that nothing but the tunnel host reaches them.
  • Cloudflare settings. Please check the zone's security settings for api.hellonear.xyz and app.hellonear.xyz (WAF, bot protection, DDoS defaults) and say what is on.
  • A rate limit at the Cloudflare edge for the API (for example on the chat, sign-in and try-out routes), so a flood is refused before it reaches the box. Numbers are yours to choose; the in-app limits above are the backstop.
  • RUNS_PER_DAY_GLOBAL on the box. The default (3000) applies if it is unset. If you set it in be.env, it must be a whole number, 0 or more, or the backend stops at start. Changing be.env needs Axel's approval as usual.
  • Smart contracts (sc/, sc/swarm): a review beyond their existing unit and sandbox tests has not been done.

For the web app (@AncungAulia)

The new answers are 429 run_rate_limited { limit, window }, 429 daily_capacity_reached { limit }, 429 auth_rate_limited, and the Autopilot issues too_frequent and too_many_schedules. The app shows its general message for them today ("could not answer. Nothing happened."); a specific line would be clearer. No rush, and nothing breaks without it.

cc @Nabil-Aufa for visibility.

Activity

  1. Lin1er commented on Nov 13, 2026

    @Lin1er
    Contributor

    Firewall on the box: checked (read-only, 13 Nov 20:58 UTC). Only the tunnel host can reach the app ports.

    The hosted box has firewall on, inbound policy DROP, and IP filter on. Inbound rules:

    Port Service Allowed from
    4000 backend tunnel host only
    3000 web app tunnel host only
    3100 landing tunnel host only
    22 SSH LAN
    ICMP — anywhere

    The other listeners can't be reached from outside either:

    • engine :4100 has no allow rule;
    • Postgres listens on 127.0.0.1 only, and so does SMTP;
    • tested from another LAN host, 4000 and 4100 both refuse.

    The hosted web app calls https://api.hellonear.xyz directly (checked in its built bundle), so every API request comes through the tunnel. cf-connecting-ip can be trusted for the per-IP limits.

    The other hosting items are still open: the Cloudflare zone's settings, an edge rate limit, and RUNS_PER_DAY_GLOBAL (a be.env change, which needs Axel's approval). I'll pass the Cloudflare ones to James, since that account is his.

  2. Lin1er commented on Nov 14, 2026

    @Lin1er
    Contributor

    @Lexirieru the two Cloudflare items are done (zone hellonear.xyz, Free plan; James set them on 14 Nov).

    Security settings, as shown in the dashboard:

    • On:
      • HTTP DDoS attack protection (always on)
      • the Cloudflare managed ruleset (always on)
      • Browser Integrity Check
      • Email Address Obfuscation
      • Replace insecure JavaScript libraries
    • Off:
      • Bot Fight Mode. It's kept off on purpose: on Free it can't be limited to some paths, and it would challenge scripted API calls, including a judge's curl from the README.
      • AI Labyrinth, Leaked credentials detection, Continuous script monitoring and Hotlink Protection.
      • No IP access rules.

    Edge rate limit (new):

    • One rule: http.request.uri.path contains "/v1/", counted per IP.
    • 60 requests per 10 s, then Block for 10 s. The Free plan allows one rule with a 10 s period and a 10 s block.
    • In the last 30 days, 26.7% of the zone's traffic matched this rule.
    • How 60 was chosen (an estimate from the web app's code, not measured): a page load sends about 10 to 20 requests, and the polls every 3 s add about 10 to 13 per 10 s. So one person has room to spare, and a few people behind one network still fit. The per-account run limits in fix: usage limits for every user and for Autopilot (#327) #328 remain the backstop.
    • Checked from outside at 03:33 UTC: GET /v1/health → 200 (revision d4a3965). A burst of 75 requests got 61 × 200 and 14 × 429, and the next request was back to 200 about 10 s later.

    The RUNS_PER_DAY_GLOBAL item is still open: it needs a be.env change, which needs your approval. The default of 3000 applies until then.

  3. added 2 commits that reference this issue on Nov 14, 2026
  4. Lexirieru commented on Nov 14, 2026

    @Lexirieru
    ContributorAuthor

    Closing: everything in this issue is done.

    • Run limits for every user and Autopilot limits: merged in fix: usage limits for every user and for Autopilot (#327) #328 (49de68b) and live on the hosted demo.
    • Box firewall and Cloudflare settings plus the edge rate limit: done by @Lin1er (comments above).
    • RUNS_PER_DAY_GLOBAL: kept at the default 3000, no be.env change. To reach it, about 10 accounts would each have to use their full 300 runs a day, and the edge rate limit slows scripts. Raising it without knowing the remaining NEAR AI credit risks running the credit out, which would stop the demo for everyone.
    • Smart contracts beyond their existing tests: not reviewed, stated under "Known limits" in the README's security review.

    @AncungAulia optional, not needed for judging: the web app could show friendly messages for the new 429 codes run_rate_limited (limit, window: hour or day), daily_capacity_reached (limit) and auth_rate_limited. @Nabil-Aufa FYI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions