Dev.to Security πŸ” Cybersecurity πŸ‘ 0 πŸ“– 3 min read

A client-side utility or energy-bill estimator still ships its tariff bands

Utilities and energy startups like a bill estimator that updates as the slider moves: tiered kilowatt-hour prices, time-of-use windows, demand charges, and a "you could save $N" comparison against a rival plan. When the

Utilities and energy startups like a bill estimator that updates as the slider moves: tiered kilowatt-hour prices, time-of-use windows, demand charges, and a "you could save $N" comparison against a rival plan. When the tariff bands, the rider codes, the seasonal switches, and the savings claims all run in the browser, you have published the pricing book β€” and a way to game the estimate or undercut you with your own numbers.

A competitor can lift the exact tiers you negotiated. A customer can hook the estimator and walk into a sales chat with a fabricated "guaranteed" savings figure that a later signup flow trusts. Neither is acceptable if that number is treated as a quote, a switch authorization, or a rebate qualification.

What actually ships

A typical client-side bill-estimator script includes:

  • Tariff catalogs β€” energy charges, service fees, minimum bills, and riders by territory and season.
  • Time-of-use and demand rules β€” peak windows, shoulder pricing, and kW demand calculations.
  • Comparison logic β€” how you pick a "current plan" baseline and compute a savings claim.
  • Eligibility predicates β€” which plans are offered to which rate class, load size, or solar configuration.
  • Unreleased or promotional rates β€” pilots, acquisition discounts, and internal staff plans.

The official enrollment can still hit a server. The function that printed "$28/month savings" is often already in the bundle.

How it gets lifted

People search the bundle for strings like tariff, peakKwh, demandCharge, or a function named estimateBill.

export const TARIFFS = {
  "res-tou-a": {
    territory: "CA-north",
    energy: { off: 0.18, mid: 0.27, peak: 0.41 },
    peakHours: ["16-21"],
    demand: 0,
    promoDiscount: 0.12,
  },
  "res-flat-b": { territory: "CA-north", energy: { flat: 0.24 }, demand: 0 },
};

export function estimateBill(usage, plan) {
  const t = TARIFFS[plan];
  let energy = 0;
  for (const h of usage.hours) {
    energy += h.kwh * rateFor(t, h);
  }
  const total = (energy + (t.serviceFee || 10)) * (1 - (t.promoDiscount || 0));
  return { total, savingsVs: total - estimateBill(usage, "res-flat-b").total };
}

Once TARIFFS is public, a promotional 12% discount is no longer a conversation with sales. If enrollment trusts a client-computed total or savingsVs, you have turned a calculator into a self-serve quote.

What actually protects you

Move official quotes off the client

  • Authoritative tariff math belongs on the server, against the current filed rates, the real interval data, and a logged estimate id.
  • Promotional and unreleased plans should not be described in a public bundle at all.
  • Switch or rebate qualification must be decided server-side, not unlocked by a query parameter.

Protect a local ballpark if you still want one

A rounded monthly range can still run locally so the slider feels alive. For that chunk:

  • Ship only coarse, already-public rate classes, not rider-level tables or acquisition discounts.
  • Bundle the ballpark separately from enrollment and rebate UI.
  • Apply stronger-than-mangling protection (control-flow flattening or VM-based compilation) to any table you still ship.
  • Leave source maps off the public CDN.
  • Re-price, or at least confirm, the bill on the server before you show a guaranteed savings figure or start a switch.

Do not treat the estimator as a quote desk

If a signup proceeds because the page said savingsVs: 28, anyone can write that number into the request. A quote that matters needs a server that already computed it.

Practical checklist

  • [ ] Enrollment quotes, guaranteed savings, and rebate qualifications are computed or confirmed on the server.
  • [ ] Promotional discounts, riders, and unreleased tariffs are not described in the public bundle.
  • [ ] Any local hint is limited to a coarse public ballpark, split from enrollment UI, and protected with stronger-than-Terser obfuscation.
  • [ ] Source maps for the estimator are not on the public CDN.
  • [ ] Hooking the estimator cannot change a quoted bill or a switch authorization.
  • [ ] Estimates that matter for audit or dispute handling are logged server-side.
  • [ ] The UI does not treat a localStorage total as a completed official quote.

Honest limits

Filed tariffs may already be public documents. Obfuscation does not hide a rate a regulator published; it raises the cost of lifting your comparison logic, promotional overlays, and unpublished pilots. If a number cannot be public, do not put it in JavaScript you send to every browser.

Summary

A client-side bill estimator ships the work that makes it powerful: the bands, the riders, and the savings claim. Use a coarse ballpark if you must, protect that chunk, and let the server be the only path that issues a quote.

Disclosure: I work on VEILVM, a JavaScript VM-protection service. Free browser tier (3 runs/day, up to 5 KB) and a Pro plan at $9/month or $79/year with API access. Try the playground at vm.ldvmp.com.

πŸ“° Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes β€” full credit and traffic to the original publisher.