Inventory the decisions that matter

List the operations that grant access, spend money, export data or change another person’s resources. Trace where each decision is made and what data it trusts. A disabled button in the browser may improve usability, but it does not authorize the matching backend operation.

For a subscription feature, the browser may show an upgrade screen based on returned account state. The server should check current entitlement when executing the feature. A client boolean such as paid=true must not substitute for that check.

Define a narrow server operation

Expose a documented request that carries the user’s intended action and necessary inputs, then authenticate and authorize it against server-controlled account data. Retrieve sensitive provider credentials inside the server operation. Return the minimum result the interface needs instead of a broad internal object.

Avoid moving the entire privileged service client into shared browser-importable modules. Review dependency boundaries and generated bundles after refactoring. Code organization alone is not evidence: an accidental import or serialized configuration can still carry a sensitive value into public output.

Test bypasses, tenants and retries

Write request-level checks using controlled test accounts. A useful matrix includes signed out, wrong tenant, insufficient role, revoked entitlement, expired session, malformed input and a valid user. Confirm the server denies unauthorized requests even when they are sent without running any page JavaScript.

Test retries and concurrent requests for operations with side effects. Some actions need an idempotency design or transactional state transition so duplicate submissions do not spend a quota or create duplicate charges. The correct mechanism depends on the actual business operation and storage system.

Connect release review to runtime review

Audit the final browser assets for known credential patterns and private maps. Review server deployment configuration separately, including logs, environment access and privileged service scopes. CloneGuard’s byte scanner does not execute authorization tests or certify the backend’s policy.

Retain a small decision table showing which actor can perform each operation on which resource. This is a more durable control than inventing unreadable field names. An agent may still learn the public API shape, while the server consistently limits what an unauthorized client can accomplish.

Review a client-to-server move end to end

For a concrete refactor, remove a privileged provider call from a client module and expose a server operation with a narrow request schema. Verify that the client bundle no longer contains the provider credential, that the server retrieves current account permissions, and that error handling does not return the provider’s full diagnostic object to the browser. Test a valid account, another tenant and a revoked entitlement. Finally, compare the user-visible result and response latency with the previous flow. A successful architectural change must preserve the product experience while moving enforcement to the trusted side.

Practical checklist

  • List privileged operations and their server checks.
  • Review shared modules for accidental client imports.
  • Test signed-out and cross-tenant requests directly.
  • Inspect returned fields and side-effect retry behavior.

Sources and further reading

Primary references support the technical details. Procedures here are guidance; only explicitly recorded project results describe tests we ran.

  1. OWASP authorization guidance
  2. CloneGuard CLI and documented scope

Prepared with AI assistance. How this library is produced. Suggest a correction; keep private code and credentials out of public issues.