Skip to main content

CookieGuard for Python

cookieguard is CookieGuard's Python package. Integrations live under it; the first is cookieguard.browser_use.

A successful agent login is not a secure session cookie. CookieGuard for Browser Use watches the browser your Browser Use agent drives, checks the authentication cookies it receives, and returns PASS / FAIL / INCOMPLETE with rule IDs, explanations, and fixes. The decision comes from the local CookieGuard policy engine, never from the model.

Overview · Install · Policy · How it works · Results · Limits & privacy · Demo & tests

Your policy decides what fails

CookieGuardAudit options decide which findings fail. High-severity rules CG001 Missing HttpOnly, CG002 Missing Secure, CG006 invalid prefix, and CG007 regression fail by default. With fail_on set to medium, CG003 SameSite and CG005 lifetime fail too. CG004 Domain sharing fails only with require_host_only. CG008 and CG009 are review only. The result is FAIL (exit 1), INCOMPLETE (exit 2, which overrides FAIL), or PASS (exit 0).

fail_on sets the line: a confirmed finding at or above it fails the run; anything below is reported. Only cookies you name in auth_cookies can be confirmed. All options and a stricter example: Policy.

See it run

A Browser Use agent logs in to two local apps. Both logins succeed. CookieGuard fails the first with CG001 Missing HttpOnly (exit 1) and passes the second (exit 0).

Claude (claude-opus-5-5) drives a real Browser Use agent through the same login twice. The insecure app's cookie lacks HttpOnly, so CookieGuard returns FAIL — CG001 (exit 1). The secure app gets PASS (exit 0). Recorded from a real run: Demo & tests.

Add it to your agent

from browser_use import Agent, BrowserProfile, BrowserSession, Tools
from cookieguard import CookieGuardAudit

audit = CookieGuardAudit(
    allowed_origins=['http://127.0.0.1:3000'],  # exact origins you are authorized to test
    auth_cookies=['session_id'],                # the real session cookie name(s)
    fail_on='high',
)
session = BrowserSession(browser_profile=BrowserProfile(
    keep_alive=True,                            # required: Agent.run() otherwise closes the browser
    enable_default_extensions=False,            # avoid the bundled cookie-consent extension
    allowed_domains=audit.browser_allowed_domains(),
))
tools = Tools()
audit.register_tools(tools)                     # optional agent-visible check

await session.start()
await audit.start(session)                      # before the login
agent = Agent(task=..., llm=..., browser_session=session, tools=tools,
              sensitive_data={'http://127.0.0.1': {'login_password': '...'}})
await agent.run()
result = await audit.finish()                   # decided by the CookieGuard engine
await session.kill()

print(result.summary)
result.assert_policy()                          # raises CookiePolicyError on FAIL or INCOMPLETE

assert_policy() raises even if the agent never called the tool, or reported success. CookieGuardAudit is also an async context manager; close() stops collection without a result. One instance audits one workflow.

The 0.4.0 usage-reporting pilot defaults on and attempts one fixed event per accepted start(). usage_metrics=False, COOKIEGUARD_USAGE_METRICS=0, or DO_NOT_TRACK=1 disables it; usage_metrics=None or omission follows the environment/default. Events use fixed package/version/integration fields, a fresh random invocation ID, and fixed privacy controls, without cookie data or audit results. The bundled public token targets CookieGuard's US Cloud project 735326. Delivery is best effort and does not change audit results. Downloads, imports, and construction do not report. Existing Python 0.3.0 installations remain unchanged until upgraded. See privacy boundaries for provider transport and Browser Use settings.

Needs Python 3.11+, Node.js 24+, and Chrome or Chromium: Install.

Install version 0.4.0 from PyPI:

pip install cookieguard==0.4.0

Code that uses cookieguard-browser-use or import cookieguard_browser_use keeps working: that package now installs cookieguard and re-exports it.

Version: 0.4.0. Historical environment validation covers browser-use 0.13.14 on Linux (Python 3.11–3.13) and macOS (Python 3.12); current release checks are recorded in VALIDATION.md. See tested environments. This is a community integration, not an official Browser Use package.

Metadata

Release files for cookieguard 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cookieguard 0.4.0
File Size Uploaded Provenance Actions
cookieguard-0.4.0.tar.gz 131.3 kB With provenance Details for cookieguard-0.4.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for cookieguard 0.4.0
File Interpreter ABI Platform Actions
cookieguard-0.4.0-py3-none-any.whl Python 3 none any Details for cookieguard-0.4.0-py3-none-any.whl

Total release size: 231.8 kB

Release files / cookieguard-0.4.0.tar.gz

Download URL cookieguard-0.4.0.tar.gz
Size 131.3 kB
Tags Source
SHA-256 checksum
How to use checksums
0c3b81be1ad97ce28dd06b1d09bb4045aa12b871de89ccda175f6153913185e8
BLAKE2b-256 checksum
How to use checksums
58f35ba32a58b756cabed2bb2f449869fabda9f2004bc630d440ba8f9cd8e0df
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 14, 2026.

Transparency log

Release files / cookieguard-0.4.0-py3-none-any.whl

Download URL cookieguard-0.4.0-py3-none-any.whl
Size 100.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ac81246f0bd0571d9b13a957f1bb05706eb0cdce33f98f6fedf2d9736a192cf8
BLAKE2b-256 checksum
How to use checksums
c74a93873ed3644cc133b091312c1ddf4977280c6628c7af89317c75ed81c641
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 14, 2026.

Transparency log

Security for cookieguard 0.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for cookieguard-0.4.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 14, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page