Skip to content

fix: release hardening, pinned deps, sanitization, Hyperliquid order checks, December bounty fixes; release v0.5.2 - #20

Merged
kuzane merged 8 commits into
mainfrom
fix/cli-hardening-remaining
Dec 2, 2026
Merged

kuzane merged 8 commits into
mainfrom
fix/cli-hardening-remaining

Conversation

@kuzane

@kuzane kuzane commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This PR collects every open minara-cli security item in one place, so it can be merged and released as v0.5.2 together with #19. It now includes #21.

# Commit What
1 c9a7b3c Release workflow hardening + PR checks (ci.yml)
2 2721262 Ship npm-shrinkwrap.json so installs use pinned dependencies
3 ad999b7 Sanitize every API response at the boundary
4 4c036af Docs: pinned deps, provenance, sanitization, limits of client-side protection
5 405ad3a Hyperliquid tick/lot formatting and per-order result checks
6 694ce47 Release v0.5.2
7 6871a1b From #21: publish from the tag-only release environment
8 b32a59d Remaining CLI findings from the December bounty table

1. Release workflow — c9a7b3c, 6871a1b

  • Actions are pinned to full commit SHAs.
  • permissions: {} at the workflow level. The publish job gets only contents: read + id-token: write.
  • The job runs in the release environment (from ci: publish to npm from the tag-only "release" environment #21). Only v* tags may deploy to it, and only admins can create tags. NPM_TOKEN becomes an environment secret, so a workflow pushed on a branch can't read it.
  • Node 24, with a check that npm is ≥ 11.5.1, so trusted publishing (OIDC) is used once it is configured. --provenance is on. The job fails if the release tag doesn't match the package.json version.
  • npm ci --ignore-scripts. No dependency cache and no persisted git credentials.
  • ci.yml runs type check, tests, build and npm audit on Node 20/22/24 for every PR. It uses pull_request with a read-only token, so fork PRs are safe.

2–4. Pinned dependencies, sanitization, docs

  • npm-shrinkwrap.json ships in the package.
  • Every API response, including Hyperliquid's, is stripped of terminal control sequences as it arrives.
  • The README documents all of this.

5. Hyperliquid orders — 405ad3a

  • Price strings: follow the official SDK, with no trailing zeros and no exponent notation (the old toPrecision(5) produced "3535.0" / "1.0201e+5"). Prices respect the 5-significant-figure and 6 − szDecimals decimal limits.
  • Input checks: --price / --size are checked against tick and lot size before anything is sent. Orders under the $10 minimum are refused up front.
  • Per-order results: Hyperliquid returns status ok even when an order is rejected, so the CLI now reads each order's status. It shows fill size and average price, warns on partial fills, and exits non-zero when the order was rejected (the original fix : close command fails to execute on Hyperliquid #13 symptom).

8. December bounty table — b32a59d

Finding Fix
M-316: perps cancel / limit-order cancel only used a plain confirm() Both now use the transaction confirmation (one prompt, full order details) and Touch ID. perps cancel reads frontendOpenOrders and warns when the order is reduce-only or a TP/SL trigger protecting a position
Order preview showed the default wallet's leverage for a sub-wallet order Leverage is read from the selected wallet. The preview and confirmation show the wallet and its leverage
M-353: truncated / unreadable config.json silently disabled Touch ID Fund operations fail closed until the file is fixed or rewritten. Config and credentials are written atomically (temp file + rename)
M-352: logout reported success when server-side revocation failed Reported as a failure, and local credentials are kept so it can be retried. --local clears them anyway. A 401 counts as already logged out and no longer triggers the re-login prompt
M-333 / M-337 / M-348: swap quote skipped with -y; no slippage bound The quote is always fetched and shown (with -y --json it is not printed, so stdout stays one JSON result). Quotes with slippage tolerance or price impact > 10% are refused (--max-slippage, --max-price-impact). An unattended -y swap is never sent without a quote
M-351: Solana recipient only checked for charset and length Must base58-decode to a 32-byte key. Off-curve (non-wallet) keys get a warning, because Solana addresses have no checksum
M-332: zero-width / invisible characters passed sanitization The sanitizer also strips zero-width characters, soft hyphen, BOM, word joiner, variation selectors, Unicode tag characters and similar, and treats U+2028/U+2029/NEL as line breaks
M-316: dev localhost base URL could leak the token to a local listener Loopback base URLs are only accepted with MINARA_DEV=1

Already fixed earlier, or by design: $TICKER fuzzy match (#19), lowering protections in config (#19, Touch ID on macOS), and -y (kept on purpose; Touch ID is never skipped).

Before publishing: live check (maintainer, ~2 minutes, ≥ $11 notional)

From this branch, run npm ci && npm run build, then:

  1. node bin/minara.js perps order -S long -s ETH -z <size worth $11–15>. Expect "Filled …".
  2. node bin/minara.js perps positions. The ETH position is there.
  3. node bin/minara.js perps close -s ETH. Expect "Closed 1 position(s)".
  4. node bin/minara.js perps positions. No ETH position is left.

Admin steps (from #21, in this order)

  1. Settings → Environments → release → Add environment secret NPM_TOKEN (the current npm token, or a fresh automation token).
  2. Merge this PR.
  3. Settings → Secrets and variables → Actions: delete the repository secret NPM_TOKEN.
  4. Optional: add required reviewers to release, and configure the trusted publisher on npmjs.com (Minara-AI / minara-cli / publish.yml / environment release). Then the token can be removed entirely.

If this is merged before step 1, the next publish fails for lack of a token. Nothing is published, and the job can be re-run.

Testing

  • npx vitest run: 425 passed (362 on main).
  • npx tsc --noEmit reports no errors; build and npm pack were checked; npm audit and pnpm audit find 0 vulnerabilities.
  • The ed25519 on-curve check was cross-checked against RFC 8032 point decoding on 4,000 random keys.

Supersedes #21.

https://claude.ai/code/session_0133E5DCA8sK7CJ7WWWrb2P7


Generated by Claude Code

publish.yml
- pin actions/checkout (v7.0.1) and actions/setup-node (v7.1.0) to full
  commit SHAs instead of movable tags
- empty workflow-level permissions; the job gets contents:read +
  id-token:write only
- run in a protected `npm-publish` environment (add required reviewers
  in repo settings so a release can't publish on its own)
- Node 24 with an npm >= 11.5.1 check, so npm trusted publishing (OIDC)
  works as soon as it is configured on npmjs.com; until then npm falls
  back to NPM_TOKEN
- `npm publish --provenance --access public`
- fail if the release tag doesn't match package.json version
- `npm ci --ignore-scripts` (no dependency needs install scripts), no
  dependency cache and no persisted git credentials in the release job

ci.yml (new)
- type check, tests, build and production `npm audit` on Node 20/22/24
  for every pull request and push to main; read-only token, no secrets
  (pull_request, not pull_request_target), so fork PRs are safe

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0133E5DCA8sK7CJ7WWWrb2P7
`npm i -g minara` used to resolve chalk / commander / inquirer / ora /
cli-table3 and their dependencies fresh at install time, so a
compromised upstream release could reach users without any change in
this repo. `npm shrinkwrap` turns package-lock.json into
npm-shrinkwrap.json, which npm honours for consumers. It is added to
`files` so it ships in the tarball (verified: a packed install gets
exactly the pinned versions). `npm ci` in CI keeps working unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0133E5DCA8sK7CJ7WWWrb2P7
- move sanitizeTerminal / sanitizeDeep to a dependency-free
  src/sanitize.ts (re-exported from utils.ts, so imports are unchanged);
  sanitizeDeep gains a `multiline` option
- the API client now strips terminal control sequences, C1 and bidi
  override characters from every string in every response (JSON and
  non-JSON, success and error), keeping line breaks; Hyperliquid public
  API responses (coin names, leverage, fills, orders) get the same
  treatment. Display paths can no longer forget to sanitize server data.
- names shown on a single line (wallets, strategies, subscription plans,
  checkout URLs, order errors, token address in limit-order) are also
  sanitized in single-line mode so a newline can't fake extra rows

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0133E5DCA8sK7CJ7WWWrb2P7
… and client-side limits

Also drops the stale note about the OAuth callback server (removed in #17).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0133E5DCA8sK7CJ7WWWrb2P7
…ults

Market orders, closes and the ask quick order priced the IOC limit with
`(mark * 1.01).toPrecision(5)`. That gives "3535.0" (a trailing zero
changes the signed payload) and "1.0201e+5" once a price passes 100,000,
and it ignored the `6 - szDecimals` decimal limit. Hyperliquid also
answers status "ok" when an individual order is rejected, so an IOC that
found no liquidity was reported as "submitted" / "closed" (the original
symptom in #13).

- new src/hl-format.ts: price formatting per the official SDK (5
  significant figures, then 6 - szDecimals decimals, plain decimal
  string), size formatting, user price/size validation, and a parser
  for per-order statuses wherever the backend nests them
- order / close / ask use it; user-entered --price / --size are checked
  against the asset's tick and lot size before anything is sent (with
  the nearest valid price as a hint) and sent without trailing zeros
- new orders under Hyperliquid's $10 minimum are refused up front
- after submitting, the CLI reports the filled size and average price,
  warns on partial fills, and exits non-zero when Hyperliquid rejected
  the order; `perps close --all/--symbol` lists partial or rejected
  closes as failures and sets exit code 1

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0133E5DCA8sK7CJ7WWWrb2P7
Ships #19 (perps execution and token lookup fixes) together with this
PR's release hardening, pinned dependencies, response sanitization and
Hyperliquid order formatting / result checks.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0133E5DCA8sK7CJ7WWWrb2P7
@kuzane kuzane changed the title fix: harden release pipeline, pin dependencies, sanitize all API responses fix: release hardening, pinned deps, response sanitization, Hyperliquid order checks; release v0.5.2 Nov 30, 2026
Folds in #21. NPM_TOKEN moves to an environment secret of "release",
which only v* tags may deploy to (tags are admin-only), so a workflow
pushed on a branch can no longer read it. The trusted-publisher setup
on npmjs.com should name this environment too.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0133E5DCA8sK7CJ7WWWrb2P7
- perps cancel / limit-order cancel (M-316): cancelling may remove a
  stop-loss or take-profit, so both now use the transaction
  confirmation (single prompt, full order details) and Touch ID like
  placing an order; perps cancel reads frontendOpenOrders and warns
  when the order is reduce-only or a TP/SL trigger
- perps order on a sub-wallet: leverage is read from that wallet's
  address, never the default wallet's; the preview and confirmation
  show the wallet and its leverage
- damaged config.json (M-353): an unreadable or non-object config no
  longer falls back to defaults silently; fund operations fail closed
  until it is fixed or rewritten via `minara config`. Config and
  credentials are written atomically (temp file + rename)
- logout (M-352): a failed server-side revocation is reported as a
  failure and local credentials are kept so it can be retried;
  `--local` clears them anyway; a 401 counts as already logged out and
  no longer triggers the re-login flow
- swap (M-333 / M-337 / M-348): the quote is always fetched and shown,
  also with -y (not printed with -y --json); quotes with slippage
  tolerance or price impact above 10% are refused (--max-slippage /
  --max-price-impact); an unattended -y swap is never sent without a
  quote
- Solana recipients (M-351): must base58-decode to a 32-byte key;
  off-curve (non-wallet) keys get a warning
- terminal sanitization (M-332): also strips zero-width characters,
  soft hyphen, BOM, word joiner, variation selectors, Unicode tag
  characters and other invisible format characters, and treats
  U+2028/U+2029/NEL as line breaks; token picker addresses are
  sanitized explicitly too
- base URL (M-316): loopback hosts are only accepted with MINARA_DEV=1,
  so a development base URL left in the config cannot send the token
  to whatever later listens on that local port

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_0133E5DCA8sK7CJ7WWWrb2P7
@kuzane kuzane changed the title fix: release hardening, pinned deps, response sanitization, Hyperliquid order checks; release v0.5.2 fix: release hardening, pinned deps, sanitization, Hyperliquid order checks, December bounty fixes; release v0.5.2 Dec 2, 2026
@kuzane
kuzane merged commit 3d75b6f into main Dec 2, 2026
6 checks passed
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.

2 participants