Anatomy of client trust chain: Google One "$0 purchase" implementation principle
Applicable readers: Front-end protocol analysis / Chrome extension development / Web attack surface assessment Keywords: batchexecute, f.req, protobuf-as-JSON, Trusted Types, MAIN world, offer redeem token, client authority (CWE-602)
- TL;DR
This suite of tools does not contain any memory corruption, credential theft, or network layer attack components. It relies on three long-underrated client-side facts:
Front-end pricing: The line item list of the subscription order (SKU, discount token, billing mode) is assembled by the page JS at the moment the order is placed, and the server basically accepts this assembly result on the analyzed link;
Loose binding of offer tokens: After the offer redemption token is issued, it is bound to the "account × device × time window" triplet that is suspected of not being strongly verified with the server, and can be held offline and delivered across accounts;
MAIN world has the same realm capabilities: world: "MAIN" injection allows extension scripts to share the same JS .realm with the page. These native exports of XMLHttpRequest.prototype.send, Element.prototype.setAttribute, iframe.src setter, and TrustedTypePolicy.prototype.createScriptURL can all be overwritten in place.
The entire work of the expansion is equivalent to setting up a transparent rewriting agent that runs synchronously on these three layers and only takes effect on the egress.
- Target link restoration
one.google.com is a typical SPA. After the user selects a package and enters checkout, there are two programmable landing points on the traffic:
Point A - batchexecute request body POST body is in the shape of f.req=<percent-encoded JSON>, double-layered grouping, and the inner layer is a call array of several [method name, string load]. This extension only cares about one of the internal RPCs: Ngbm (submit/revalue shopping cart, semantics is inference), whose string payload is serialized into a layer of JSON:
code block
f.req = urlEncode( JSON.stringify(
[ [ ["Ngbm", '<payload-json-string>' ], ... ], ← 1st set of calls
] ) )
payload ≈ [ node0, node1 ] ← Two parallel proto-as-JSON trees
Point B - Acquisition iframe The settlement page is hosted by an iframe, in the shape of tokenized.play.google.com/…/eacquire/multiline?...&ear=<json>, where ear is a JSON-based acquisition context, and there is also a layer of base64-wrapped JSON onion structure embedded in it (described later).
To complete the rewriting before "click to pay", both lines must be covered at the same time. If one is missing, there will be a disconnection of "the estimated price is correct, but the official deduction has not been changed".
- Extended Anatomy and Permission Posture
File World / Occasion Responsibilities
inject.js MAIN · document_start four native export overrides + two sets of payload rewriting engines
presets.js ISOLATED · document_end stall/token data model (actually the "wallet")
content.js ISOLATED · document_end floating control panel, storage persistence, message bridge
play_guard.js MAIN · idle · all_frames Settlement amount in iframe bypass monitoring (DOM text scoring)
popup.js/html / background.js — toolbar selection / empty background
Three points of engineering judgment are worth mentioning:
Permission convergence: host_permissions has only four business domain names; no debugger, no declarativeNetRequest, and no remote script. The work of the network layer is all done by rewriting the MAIN world in place, rather than intercepting/transmitting it on behalf of others - the extension never actively initiates any purchase requests, but only modifies the requests issued by the page itself.
The three content scripts perform their own duties: inject.js must use document_start + MAIN to install the hook before the site frame sends the first request; content.js only needs to build the UI, so it is more stable to stay in the isolated world (the page script cannot sense it); play_guard turns on all_frames: true because the settlement structure is a multi-level iframe nesting, and it deliberately skips the top-level window and only draws banners in sub-frames.
Double world handshake: The only legal channel between the MAIN and ISOLATED worlds is window.postMessage and DOM properties, which determines all subsequent message designs.
Communication topology:
code block
[popup] ──tabs.sendMessage──▶ [content.js (ISOLATED)]
│ window.postMessage({__g1pk:1,type:'cfg'})
▼
[inject.js (MAIN)] ──Override──▶ Create page native XHR / iframe
▲
└── state receipt (mounted:true → panel lights green)
- The first layer: Overwriting the prototype chain of the same realm
The four hooks of inject.js under document_start (marked: ①② are "main exits", ③④ are supplementary):
XHR export: wrap XMLHttpRequest.prototype.send, the hit condition is only "body is a string and contains Ngbm", and then handed over to rewriteFreq() for decoding → operation → recoding (§4).
Trusted Types export: wrappers TrustedTypePolicy.prototype.createScriptURL. Note that this does not bypass TT - the rewritten URL still needs to be sent to the original policy for verification, and it will be released only if it is legal. Here is the rewrite flow parameter "down the site's compliance pipeline".
iframe attribute export: After taking the original attribute descriptor, use defineProperty to wrap the setter of HTMLIFrameElement.prototype.src (getter/configurable/enumerable are all left intact to avoid damaging the reflection logic of the frame itself).
Universal attribute export: wraps Element.prototype.setAttribute, only intervenes when "the target is an iframe and the attribute name is src (case normalized)".
Why spread it all around? Because the Google front-end creates a settlement iframe, there are multiple independent source paths: hard-coded attributes in the template, assignment to .src at runtime, and URLs distributed through the TT strategy. If any one is not caught, an iframe will be missed. The three items (policy/property/attribute) cover all known writing methods.
Two permeable implementation disciplines have more reference value than the hook itself:
fail-open: Each hook and each parsing is wrapped in try/catch, and it is transparently transmitted as it is when it fails. I would rather this rewrite be invalid than never block users from checking out - the side effect is that all faults will be swallowed up, making online troubleshooting difficult.
Synchronicity: All rewriting occurs at the same time as the method is called, without any asynchronous timing assumptions. The meaning of the source code comment "Do not click the page" is this: the script does not simulate clicks, the user clicks slowly, and the hook ensures in the dark that every export traffic is a rewritten version.
- Second level: "Designated surgery" of f.req
The process of rewriteFreq() is a strict decode → traversal positioning → subtree replacement → limited writeback:
js
body.split("&") // Only move the part where f.req= is located
→ decodeURIComponent(slice(6))
→ JSON.parse // Get grouped array
→ Double-level for: find call[0] === "Ngbm" and call[1] is a string
payload = JSON.parse(call[1])
patchNode(payload[0]); patchNode(payload[1]) //Try each of the two proto-as-JSON trees
call[1] = JSON.stringify(payload) //Write back only after success
→ encodeURIComponent → join("&")
The confidence to dare to fully re-stringify is that the key order of JS objects remains stable in the insertion order during the serialization round trip, and the array is inherently ordered. Therefore, JSON.parse ⇄ stringify is a conformal transformation, and the peripheral batchexecute structure will not be distorted by rearrangement.
The writing position of patchNode() is carried out according to the subscript depth (the payload is the style of "protobuf field number as array subscript", the semantics are inferred from the request sample):
Site Write Inferred Meaning
node[12] full_items line item collection (level one)
node[10][0] [full_items] Second-level encapsulation of line items (candidate snapshot)
node[2][2][8] [full_items] The third redundant copy of the same data
node[7] (or node[6]) [null, mode, null, null, null, [subId]] Billing/renewal mode construction
A few intriguing details:
Extra copies must be modified together. The same items data coexists in ≥3 redundant forms. If only one of them is changed, the server will always read the one that has not been changed and then roll back to the original price - this is a typical "multi-point redundancy check" protocol design (a redundant backup for the defender, and a full alignment burden for the attacker).
The subId is obtained by "stealing from the field": when processing patchNode, it first reads the real subscription context ID from the original requested node[7][5][0] and then backfills it to the newly constructed node[7]. This determines the parasitic nature of the extension - it does not construct a new session, but waits for the user to walk to the checkout page, borrows the legal shell generated by the page, and only exchanges "goods".
mode defaults to 5 (observable constant, suspected to be an enumeration value such as "apply offer according to the current cycle", but has not been verified).
Signature of line item tuple (measured format, semantic inference):
js
makeItem = (sku, token) =>
[ [ "subs:com.google.android.apps.subscriptions.red:" + sku, 21 ],
null, null, null,
1, // Suspected quantity or a certain Boolean commitment bit
[ token ] ] // Discount token slot
21 is a consistent observed constant value across the entire site; the product identification uses the Android in-app purchase style RPC path prefix (subs:com.google.android.apps.subscriptions.red:), which does not change even if the page is Web - this shows that the Web checkout is reusing Play's subscription core.
- The third layer: ear parameters and "onion" core
rewriteUrl() handles drop point B. For each URL containing /eacquire/multiline, remove ear and do four steps:
js
ear[13][0] = full_items // Shell layer: line items
inner = JSON.parse(atob(ear[4][0])) // Peel back the base64 onion
inner[8] = [full_items] // Inner core layer: the same data
ear[4][0] = btoa(JSON.stringify(inner)) // Seal back
ear[8] = <Pattern structure isomorphic to node[7]> // Pattern layer, if it cannot be obtained, it will also be mirrored from the context.
ear[24] = null // Observation: The original value is suspected to be a challenge/verification structure, leave it empty and take the non-challenge branch (inference)
The core difficulty lies in the consistent alignment of multiple packages: shell 13, inner core [8], and mode layer 8 must all point to the same full_items. If any two layers are inconsistent, different readers of the protocol (evaluator, charger, risk detector) may get different views of the world—at least the price on the page may be right or wrong, or at worst, risk control may be triggered. This is the step with the highest engineering content in the entire code: it requires first understanding how many copies of the "same truth" the protocol has copied and who they have fed them to.
In conjunction with ear, there are three iframe interceptions in §3 - ear only appears on the settlement URL to be created, so the rewriting must occur at the moment when "the URL becomes the attribute value".
- Level 4: Token Economics
presets.js is the data layer, which is essentially a mapping table of SKU × duration → token:
Gear level product path token prefix (actual measurement)
20TB · 12/6/3/1 month g1.play.20tb AYrTWi… Varies
30TB · 12/6/3/1 month g1.play.ai.pro AYrTWi… Varies
YouTube Premium add-on g1.youtube_premium_individual_add_on AVbCH/… constant
Three structural observations:
One order has multiple lines, and each line is written off independently. The constructor always generates two items: the main package + the YouTube add-on package, and the latter always has the same dedicated token. This proves that the checkout pipeline supports "multi-line items in the shopping cart, each line comes with its own redeem token for deduction" - the reason why the superposition of "main package $0 + additional package $0" is established is due to the row-level billing model.
Tokens are assets and extensions are wallets. The UI allows users to paste override tokens, persisted in chrome.storage.local (key g1ZcTokenOverrides). This means that the community does not need to issue extensions when distributing new tokens - the acquisition channel for tokens (Telegram channel) is decoupled from the consumption tools.
Vulnerability originates from the same source: The "This plan has no token" branch in selectPreset() indicates that some gears have never received available tokens; and once the server tightens verification of such static tokens (binding the issuing account, one-time write-off, and introducing aging), the entire table will be scrapped overnight.
The supporting auxiliary hand is the tax-free state address filling: fillUsTaxFreeAddress() locates the form item through the regular matching of aria-label/placeholder/parent label, automatically fills in Oregon (Portland, OR 97201, no state sales tax) and dispatches synthetic input/change events to penetrate the front-end validation. The rule it uses is very simple - tax rate = ZIP filled in by the user, which is an arbitrage of the last penny of the obtained price.
- Verification loop: play_guard's "spectator score"
Since the server is the final arbiter (qualification, region, inventory, risk control), any modification on the client only improves the hit rate but does not guarantee success. play_guard.js is therefore designed as an honest measuring instrument: use the keyword set ($0.00 / free trial / you will not be charged vs /mo after / pay immediately...) in the settlement sub-frame to perform two classifications on body.innerText, 1.2s/3s/6s triple sampling plus MutationObserver Continuous re-judgment, with the top color bar (green = detected for free, red = no payment if not detected, yellow = mixed or loading) giving an instant visual conclusion.
This is a product decision worth pointing out separately: the author does not pretend that "injection equals success", but returns the final decision-making power to the price copywriter and the user's naked eye - for tool-based reverse engineering projects, this is the cheapest and elegant way to deal with uncertainty.
- Defender's Perspective: Closure List for this crossing
From a server perspective, the cost of blocking is actually not high:
Token tightening: redeem token is bound to the three elements of "issuance account × device fingerprint × short time limit", with one-time cancellation, and real replay protection implemented on the server side;
Authoritative quotation on the server side: whitelist comparison of line items in the Ngbm payload - cross-validation of SKU, time limit, and token. Prices are always subject to recalculation on the server side. Client submissions are only expressions of intention (standard answers to eradicate CWE-602/915 problems);
ear core signature: ear adds HMAC + timestamp to prevent silent rewriting in base64 onion;
In turn, this code itself has negative lessons to learn from: the message bridge is postMessage(..., "*") throughout and the listening side does not verify event.origin. Any third party that can execute scripts in the page context can forge {__g1pk:1,type:"cfg"} to hijack the gear control - the repair only takes five lines.
please Log in or Register an account Participate in discussions, download exclusive add-ons or unlock level posts.