Threat model
This page says what counts as a security vulnerability in HyperAdmin and what does not. Every
admin library draws the line between its job and your job in a different place, and nobody can
guess where we drew ours, so it is written down. Check it before you report, and see
SECURITY.md for how
to report.
Scope
In scope: the code in the hyper-admin package and the first-party plugins in this repository
(hyperadmin-reports, hyperadmin-tasks, hyperadmin-logfire).
Out of scope: the host application, the reverse proxy, the ASGI server, TLS, the database and its permissions, the models and business logic you register, third-party plugins, and identity providers such as Google or GitHub. A flaw in one of those is theirs to fix, even when it is only reachable through the admin.
What we trust
| Input | Trusted? |
|---|---|
Request bodies, query strings (search, sort_by, filters, page), cookies |
Untrusted |
Origin and other request headers |
Untrusted |
| Uploaded file content, file name and declared content type | Untrusted |
| WebSocket messages and OAuth callback parameters | Untrusted |
Admin(...) arguments and HyperAdminSettings (including secret_key) |
Trusted |
Your ModelAdmin classes, models, templates in template_dirs, and plugins |
Trusted |
| Forwarded headers, when the ASGI server is configured to trust the proxy | Trusted |
Anyone who can write the configuration or install a plugin already controls the process. We do not defend against them.
What we guarantee
When the admin is configured as documented, a vulnerability is any way for an untrusted input to do one of these:
- Reach a page or action without the authentication or permission it requires.
- Pass a state-changing request when
csrf_moderesolves toenforce. - Run SQL the admin did not build. List sorting is checked against the sortable columns, and search and filters go through SQLAlchemy.
- Inject script into a built-in page through a stored or reflected value that the templates should have escaped.
- Write, read or list outside the storage root through the file storage backends.
- Expose or let someone forge a session, CSRF token or
secret_key. - Export a list's rows without
view_<model>andexport_<model>, or export rows thatget_querysetor theobject_permission_checkerkeeps from the user, or a sensitive field. - Put a cell in an exported CSV or XLSX file that a spreadsheet runs as a formula: text cells that
start with
=,+,-,@, a tab or a carriage return are written with a leading'.
What you are responsible for
- Authentication. With no
auth_backendand noauth=, the admin is open. That is the default, so put authentication in front of any admin that is reachable by anyone you do not trust. secret_key. SetHYPERADMIN_SECRET_KEYto a real secret. The admin refuses to start with the default when auth or CSRF enforcement is on, and only warns indebugmode.- CSRF with host-managed auth. The admin cannot see authentication done by your own
middleware. Set
csrf_mode="enforce"yourself; under"auto"such an admin has no CSRF check. - TLS and cookies. Terminate TLS in front of the admin. Behind a proxy that does not forward
the scheme, set
cookie_secure=True. - Rate limiting. It is off unless you set
rate_limit_requests, and the built-in limiter is per process, so N workers allow N times the limit. Pass a sharedrate_limiterfor more. - Request size. Set body size limits in your server or proxy.
- Uploads.
max_sizeandallowed_typesare optional, andallowed_typescompares the content type the client declared. Set both, and treat the stored file name and content as untrusted. Files the admin serves itself getX-Content-Type-Options: nosniff,Content-Security-Policy: sandboxand attachment disposition; if you expose the storage directory or bucket some other way, those headers are yours to set. - Exports.
export_<model>is granted to no one by default; whoever you grant it to can download every row they can view, up toexport_max_rowsper file.get_querysetis the admin's row-level security, so a scoping rule that lives elsewhere (a query parameter, a template) does not apply to the file. JSON exports are not neutralised against formulas: if you load them into a spreadsheet, that import is yours to make safe. - Permissions you define. The admin enforces the permissions you configure. Granting a role too much is a configuration choice, not a bug.
- Dependencies and the database. Keep them patched, and give the database account only the rights the admin needs.
Not a vulnerability
| Report | Why it is not one |
|---|---|
| The admin works with no login | No auth backend is configured. Open is the default and is documented. |
| A logged-in superuser can read or change any record | That is what the role is for. |
An exported cell starts with ' |
That is the formula-injection guard: text that a spreadsheet would run is prefixed so it shows as text. |
| Large uploads or request bodies use a lot of memory | Size limits are optional and set by you, in the server or in max_size. |
| Many login attempts are not blocked | Rate limiting is off by default. Turn it on, and use a shared limiter with several workers. |
CSRF succeeds against an admin under host-managed auth with csrf_mode="auto" |
The admin cannot see that auth. Set csrf_mode="enforce". |
| A file whose declared type is allowed has other content | allowed_types checks the declared type. Validate content if you need it. |
| Session cookie sent over plain http | You served the admin over http. Terminate TLS and set cookie_secure. |
Default secret_key accepted in debug mode |
Debug is for development, and it logs a warning. |
| Anyone with write access to settings, templates or plugins can run code | They already control the process. |
| Findings in a dependency with no path through the admin | Report it upstream. Dependency advisories are handled by the weekly audit. |
Missing page-level security headers, such as CSP, HSTS or X-Frame-Options |
Set them in your proxy or middleware. Only served uploads get headers from the admin. |
Version disclosure, stack traces in debug mode, or scanner output with no exploit |
Not exploitable on their own. |
If it is not on the list
If a report is not listed here, send it anyway. When it turns out to be a real gap in the line between our job and yours, we fix the code and update this page.