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

A client-side grammar or style checker still ships its entire rule pack

In-browser grammar and style checkers feel magical: the underline appears before the keystroke has even settled, and no text is sent to a server. Product pages lean on that privacy story. The less-advertised consequence

In-browser grammar and style checkers feel magical: the underline appears before the keystroke has even settled, and no text is sent to a server. Product pages lean on that privacy story. The less-advertised consequence is that the rule pack β€” the actual product β€” is sitting in the JavaScript the browser already has.

If your differentiator is a carefully written set of grammar, tone, and house-style rules, shipping them in clear JavaScript is how a competitor clones the checker in a week.

What a client-side checker really downloads

A typical "runs 100% in the browser" writing assistant includes:

  • Rule definitions β€” patterns, part-of-speech conditions, exceptions, and the message templates shown to the author.
  • Style guides β€” formal vs. casual tone, banned words, inclusive-language substitutions, brand capitalization, and locale variants.
  • Scoring and severity β€” what counts as an error vs. a suggestion, and how the "writing score" is computed.
  • Dictionaries and confusion sets β€” accept/reject lists, domain jargon, and pairs like affect/effect with the disambiguation heuristics.
  • Auto-fix rewrites β€” the functions that produce the one-click replacement, including the edge cases you spent a quarter polishing.

The UI is not the product. The rule pack is.

How it gets copied

Rule packs are unusually easy to harvest because they are data. Attackers search the bundle for message strings ("Consider a more concise alternative") or for regexes that look like grammar rules.

export const RULES = [
  {
    id: "passive-voice-1",
    locale: "en-US",
    severity: "suggest",
    re: /\b(is|are|was|were|be|been|being)\s+(\w+ed)\b/i,
    message: "This looks like passive voice. Consider an active verb.",
    suggest: (m) => null,
  },
  {
    id: "brand-cap",
    locale: "en",
    severity: "error",
    re: /\bacmecloud\b/,
    message: "Capitalize the product name as AcmeCloud.",
    suggest: () => "AcmeCloud",
  },
];

export function score(matches, wordCount) {
  const errors = matches.filter((m) => m.severity === "error").length;
  return Math.max(0, 100 - errors * 8 - (matches.length - errors) * 2);
}

A competitor does not need your React components. They export RULES and score, drop them into their own editor, and now they have your house style and your scoring curve.

What actually protects you

Keep the valuable pack off the public bundle

  • Enterprise house-style packs (a customer's legal terms, banned claims, capitalization) should be fetched after authentication and executed in a context that is not a world-readable CDN file. Better: run those packs on a server or in a session-scoped worker you control, and send back annotations.
  • Scoring that affects grades, hiring, or publishing gates must be computed or re-checked server-side. Otherwise a candidate hooks score and submits a 100.
  • Licensed linguistic data should not be shipped in full to every anonymous visitor.

If a lightweight checker must run locally

Instant underlines on every keystroke may still need a local subset:

  • Ship a small, public-safe core for typo-level checks. Keep premium tone, brand, and domain packs behind auth or on the server.
  • Bundle the rule interpreter separately and protect it with control-flow or VM-based obfuscation so the rules are not a clean JSON array.
  • Encrypting the JSON and decrypting it in the same bundle is not protection; the key is sitting next to the ciphertext.
  • Rotate pack identifiers and measure whether stolen subsets still match your public messages.
  • Leave source maps off the public CDN.

Respect the privacy claim

If you promised "we never send your text to a server," do not quietly start uploading paragraphs. Offer a clear mode: private local core, or a server-assisted premium pack the user opts into.

Practical checklist

  • [ ] Enterprise and licensed rule packs are not in the anonymous public bundle.
  • [ ] Grades, hiring scores, or publish gates are re-checked on the server.
  • [ ] The local core pack is a deliberate subset, not the whole product.
  • [ ] Rule data is not left as readable JSON next to a decryption key in the same file.
  • [ ] The interpreter and premium packs are obfuscated (control-flow or VM), not only minified.
  • [ ] Source maps for the checker are not on the public CDN.
  • [ ] Privacy copy matches what the network tab actually does.
  • [ ] Auto-fix output that could be legally sensitive is reviewed; do not hide a disclaimer only in the client.

Honest limits

Obfuscation slows down someone who wants a clean export of your rules. It will not stop a patient linguist from collecting messages and reproducing a similar pack. The real control is: do not ship the pack that is your business.

Summary

A client-side grammar checker ships its rule pack, severity map, and scoring curve to every typist. Keep enterprise and licensed data off the public bundle, re-check any score that matters on the server, and protect the local core you truly have to run on the keystroke.

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.