Skip to content

fix(ui): reject non-decimal input in toNumber() to prevent hex/scientific notation bypass - #107905

Closed
lsr911 wants to merge 1 commit into
openclaw:mainfrom
lsr911:fix-toNumber-nondecimal
Closed

lsr911 wants to merge 1 commit into
openclaw:mainfrom
lsr911:fix-toNumber-nondecimal

Conversation

@lsr911

@lsr911 lsr911 commented Jul 15, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

The shared toNumber() helper uses JavaScript Number() conversion, which
accepts hex (0x10), scientific (1e3), and leading-plus (+1) notation. This
allows non-decimal input to silently pass form-field validation in the
Control UI.

Why This Change Was Made

  • Add a strict decimal regex (/^-?(?:\d+(?:\.\d*)?|\.\d+)$/) that only
    accepts plain decimal strings
  • Preserve the optional leading minus sign so that negative plain
    decimals (-1, -3.5, -0.25) continue to work for all callers
  • Reject hex, scientific, and leading-plus notation at the parser level
  • Add focused test coverage for accepted and rejected syntax

User Impact

  • Before: 0x10 and 1e3 were silently accepted as cron intervals
  • After: non-decimal input returns the fallback; negative decimals still work

Verification

  • Focused suite: ui/src/lib/format.test.ts — toNumber test block
    covering positive/negative integers, negative decimals, zero, hex
    rejection, scientific rejection, leading-plus rejection, whitespace,
    and non-numeric strings

Risk / Compatibility

Low. The strict regex preserves both positive and negative plain decimals.
Only hex, scientific, and leading-plus inputs change behavior — these were
never valid form-field inputs.

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Jul 16, 2026
@clawsweeper

clawsweeper Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 15, 2026, 10:18 PM ET / July 16, 2026, 02:18 UTC.

Summary
Changes the shared Control UI toNumber() helper to accept only unsigned plain-decimal strings and adds focused unit coverage for accepted and rejected syntax.

PR surface: Source +8, Tests +57. Total +65 across 2 files.

Reproducibility: yes. The current implementation uses JavaScript Number() conversion, and the related Control UI PR documents a current-main runtime reproduction where 0x10 and 1e3 are accepted as recurring intervals.

Review metrics: 1 noteworthy metric.

  • Shared parser contracts: 1 changed. The patch changes the semantics of a utility used outside the reported cron field, so maintainers should review the intended signed-number contract before merge.

Merge readiness
Overall: 🦪 silver shellfish
Proof: 🦪 silver shellfish
Patch quality: 🦐 gold shrimp
Result: blocked until real behavior proof from a real setup is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • Preserve negative decimal conversion or scope the unsigned parser to positive-only fields, with regression coverage.
  • [P1] Add redacted after-fix Control UI or controller-runtime proof for invalid and valid decimal input.
  • Reconcile the parser ownership and overlap with fix(ui): reject nondecimal cron repeat amounts #107480.

Proof guidance:

  • [P1] Needs real behavior proof before merge: The PR provides focused unit tests and source-level JavaScript examples, but no after-fix real Control UI run; add a redacted recording, terminal/live output, or controller-runtime transcript showing rejected invalid input and accepted valid decimal input, then update the PR body to trigger review or ask a maintainer for @clawsweeper re-review.

Risk before merge

  • [P2] Merging this branch changes a shared numeric-conversion contract beyond cron and can silently turn previously accepted signed decimal input into each caller's fallback value.
  • [P1] The branch lacks real after-fix proof that cron fields reject the unwanted syntax while valid decimal entry and non-cron numeric filters continue to behave correctly.

Maintainer options:

  1. Preserve signed decimals before merge (recommended)
    Allow an optional leading minus in the shared decimal contract or scope the unsigned parser to positive-only form fields, add regression coverage, and provide live Control UI proof.
  2. Consolidate on the narrower cron PR
    Pause this branch and extend fix(ui): reject nondecimal cron repeat amounts #107480 only if maintainers prefer a cron-owned parser rather than changing the shared utility contract.

Next step before merge

  • [P1] Ask the contributor to correct the signed-decimal regression, coordinate the overlapping cron parser direction, and provide real after-fix Control UI evidence before another merge review.

Security
Cleared: The two-file TypeScript change adds no dependency, workflow, permission, secret-handling, downloaded-code, or other concrete security or supply-chain concern.

Review findings

  • [P2] Preserve negative decimal values — ui/src/lib/format.ts:142
Review details

Best possible solution:

Use one explicitly named plain-decimal parser for the intended form fields, preserve signed decimal behavior where the generic helper promises number conversion, reconcile the overlap with #107480, and prove the resulting Control UI save and validation paths live.

Do we have a high-confidence way to reproduce the issue?

Yes. The current implementation uses JavaScript Number() conversion, and the related Control UI PR documents a current-main runtime reproduction where 0x10 and 1e3 are accepted as recurring intervals.

Is this the best way to solve the issue?

No. Centralizing plain-decimal parsing is sensible, but an unsigned regex on the generic toNumber() helper is broader than the reported bug and regresses negative decimal conversion; an explicit parser contract with caller-appropriate positivity checks is safer.

Full review comments:

  • [P2] Preserve negative decimal values — ui/src/lib/format.ts:142
    The new regex has no optional minus sign, so toNumber("-1", fallback) and toNumber("-0.5", fallback) now return the fallback even though these are plain decimal numbers accepted by the existing shared helper. Preserve signed decimals with an optional -, or move the unsigned rule into a positive-only cron parser so unrelated callers do not inherit this silent behavior change.
    Confidence: 0.96

Overall correctness: patch is incorrect
Overall confidence: 0.93

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 08ecf63bb608.

Label changes

Label changes:

  • add P2: The PR addresses a real Control UI validation bug with limited blast radius, but its shared-helper regression and missing live proof require normal-priority follow-up.
  • add merge-risk: 🚨 compatibility: The unsigned regex changes previously accepted signed decimal input into fallback values for every caller of the shared helper.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦐 gold shrimp.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR provides focused unit tests and source-level JavaScript examples, but no after-fix real Control UI run; add a redacted recording, terminal/live output, or controller-runtime transcript showing rejected invalid input and accepted valid decimal input, then update the PR body to trigger review or ask a maintainer for @clawsweeper re-review.

Label justifications:

  • P2: The PR addresses a real Control UI validation bug with limited blast radius, but its shared-helper regression and missing live proof require normal-priority follow-up.
  • merge-risk: 🚨 compatibility: The unsigned regex changes previously accepted signed decimal input into fallback values for every caller of the shared helper.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR provides focused unit tests and source-level JavaScript examples, but no after-fix real Control UI run; add a redacted recording, terminal/live output, or controller-runtime transcript showing rejected invalid input and accepted valid decimal input, then update the PR body to trigger review or ask a maintainer for @clawsweeper re-review.
Evidence reviewed

PR surface:

Source +8, Tests +57. Total +65 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 9 1 +8
Tests 1 57 0 +57
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 66 1 +65

What I checked:

  • Shared parser regression: The added unsigned regex rejects valid decimal strings such as -1 and -0.5, although the existing Number(value) implementation accepts them and the stated scope only identifies hexadecimal, scientific, and leading-plus syntax as problematic. (ui/src/lib/format.ts:142, cfd54fcdd210)
  • Current-main behavior: At the reviewed main SHA, toNumber() directly applies Number(value) and therefore preserves signed decimal input; the PR changes this shared helper contract rather than adding only the reported non-decimal rejection. (ui/src/lib/format.ts:142, 08ecf63bb608)
  • Non-cron caller surface: The shared helper is also used for session-list numeric filters, so the change is not isolated to cron validation and needs contract-level coverage or a narrower parser boundary. (ui/src/ui/controllers/sessions.ts, 08ecf63bb608)
  • Related implementation: fix(ui): reject nondecimal cron repeat amounts #107480 addresses the recurring-interval case with a dedicated positive plain-decimal parser and includes before/after controller-runtime evidence; it partially overlaps this broader proposal but does not cover every field claimed here. (ui/src/lib/cron/index.ts, 66933310d7ff)
  • Proof gap: The PR body reports focused unit tests and demonstrates JavaScript's pre-fix Number() behavior, but it does not show an after-fix create/edit flow or another real Control UI setup exercising the changed shared parser. (ui/src/lib/format.test.ts:305, cfd54fcdd210)
  • Feature history: Control UI history shows sustained ownership by steipete across the original dashboard and session-management implementation, with cpojer carrying major early UI TypeScript and formatting work around the shared utility surface. (ui/src/ui/controllers/sessions.ts, 6ff8371)

Likely related people:

  • steipete: Introduced the expanded Control UI dashboard and has repeatedly maintained adjacent session and UI behavior, making this the strongest routing candidate for the shared parser boundary. (role: feature introducer and recent area contributor; confidence: high; commits: 6ff8371, 929b86e, 382158f; files: ui/src/ui/controllers/sessions.ts, ui/src/lib/format.ts, ui/src/lib/cron/index.ts)
  • cpojer: Carried substantial early Control UI TypeScript, lint, module-resolution, and formatting work touching the utility layer's historical ownership. (role: major UI refactor contributor; confidence: medium; commits: 27677dd, 6e09c11, f06dd8d; files: ui/src/ui/format.ts, ui/src/lib/format.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

Add an optional leading minus sign to the STRICT_DECIMAL_RE regex so
that negative plain decimals (-1, -3.5, -0.25) are accepted while hex
(0x10), scientific (1e3), and leading-plus (+1) notation remain rejected.

The original PR (openclaw#107905) inadvertently dropped negative number support
by using a regex without the optional minus sign. This restores the
prior contract for callers that pass negative decimal strings.

Co-Authored-By: Claude <[email protected]>
@lsr911
lsr911 force-pushed the fix-toNumber-nondecimal branch from cfd54fc to 7ba8432 Compare July 16, 2026 06:37
@openclaw-barnacle openclaw-barnacle Bot added the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Jul 16, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Jul 16, 2026
@lsr911

lsr911 commented Jul 17, 2026

Copy link
Copy Markdown
Contributor Author

Self-close: unranked + needs proof deadlock. Freeing capacity for higher-value PRs.

@lsr911 lsr911 closed this Jul 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant