Restricting file uploads in Strapi

Strapi accepts files through the Media Library and the upload API, so size limits, permissions and storage location need to be set before go-live. This page covers the settings to review and the trade-offs behind them.

On this page

Restricting file uploads in Strapi before go-live

Strapi file upload restrictions start with a plain question: who can put a file into the system, how large can it be, and where does it end up? An editorial or API team that has Strapi running often answers only the first part. Strapi accepts files through more than one path, and each path needs its own control. The admin Media Library is used by signed-in administrators and editors. The Content API accepts uploads when the Users & Permissions plugin grants the upload permission to a role, which for the Public role means anonymous visitors. Custom routes and controllers that your developers wrote can also accept files and bypass the defaults entirely. Before go-live, list every path, confirm which role can use each one, and check the custom code for any route that reads multipart input.

A review is needed whenever the application is public-facing, when user-generated content is possible, or when the data set is regulated, such as records that carry personal data or financial documents. In those cases, the default settings should be treated as a starting point, not a finished control. The main setting to review is the sizeLimit value in the upload configuration, which caps the size of a single file, and the body parser limits that govern the overall request size. These two values work together: a large request can fail at the parser before the upload plugin sees it, and a generous sizeLimit does not help if the parser rejects the request first. Ask your developers to confirm both values in the environment that will run production, and test a file just over each limit to see which one responds.

Which upload paths Strapi exposes and who controls each

Editors upload media through the Media Library in the admin panel, and their access is governed by the admin role-based access control rather than by the public API. Roles define whether a user can create, read, update or delete media assets, and the admin panel's upload path does not depend on the Users and Permissions plugin. Because editors are often the largest group of uploaders, reviewers should not assume that API-level restrictions cover them.

  • Media Library permissions: Review which admin roles can create and delete assets in the Media Library, and confirm the exact action names in your version's role settings.
  • Size enforcement: Test whether an editor upload above the configured sizeLimit is rejected with a clear error, and record the response.
  • Admin session scope: Confirm that admin sessions expire as configured, since an unattended session is an upload path too.
  • Role separation: Check that content roles used for editing do not also carry rights to manage upload settings or providers.
  • Audit visibility: Determine whether uploads are logged, and if audit logs are a requirement, confirm which plan provides them.

For each admin role, upload a file just over the limit and a permitted file, then confirm the results match the role matrix you documented.

Upload settings and when each one fits

This table compares five controls that shape uploads in Strapi: the upload plugin size limit, the server body parser, role permissions, custom type checks and an external provider. Each row shows what the control governs, where it is set and what it leaves open, so you can combine them rather than rely on one. Confirm default values against your installed Strapi version before you set any limit.

ControlWhat it controls and where it is setWhat it does not controlWhen to use it
Upload plugin sizeLimitMaximum file size the upload plugin accepts, set under the upload provider settings in config/plugins.js (confirm the exact key for your version)Request size for other routes, file type, who may upload, or what happens to the file after it is storedAlways set it explicitly so editors get a clear error for oversized media and the limit is documented for reviewers
Server body parser limitsMaximum request body size the Koa body parser accepts, set in the middleware configuration in config/middlewares.jsWhich user may send the request, file type, or per-field limits; it applies to every route, not only uploadsUse it as a backstop for all request bodies, and raise it only for specific routes if a real need exists
Role-based upload permissionsWhich roles can create, read or delete files in the upload plugin, set in the Users and Permissions role configuration in the admin panelFile size, file type, or where bytes are stored; an allowed role can still send a large or unsafe fileRestrict uploads to authenticated editors or trusted roles, and keep the Public role without upload rights
File type and extension checks in custom codeAllowed MIME types and extensions, enforced in a custom controller, policy or middleware in your project source (for example, under src/api)Size limits by themselves, and content that passes the check but is malicious; checks on the name alone are easy to bypassUse when only certain document or image types are valid, and inspect content type on the server rather than trusting the client header
External upload providerStorage location and delivery of files through a provider plugin configured in config/plugins.js, keeping bytes off the application serverUpload size or who may upload; the application still receives the request first unless you use a direct-upload designUse when files must sit in controlled object storage, when the application server should not hold media, or when storage needs separate backup and retention

Setting upload limits in a Strapi project

This sequence sets one maximum upload size at every layer that receives the request, removes upload rights from roles that do not need them, and moves stored files off the application server. Each step ends with a test that shows the limit holds.

  1. Inventory upload paths and roles

    List every place that accepts a file: the Media Library in the admin panel, the upload endpoints in the Content API, any custom controllers, and any plugin that accepts multipart requests. For each path, record which roles can reach it, including Public, Authenticated and any custom roles in Settings under Users & Permissions. Your security or platform lead should sign off the table before you change settings. Done means every upload path has a named owner and an expected set of roles.

  2. Set the size limit in the upload plugin

    In config/plugins.js, set the upload plugin's sizeLimit under the upload configuration. Strapi treats this value as a size in bytes, so confirm the unit against the docs for your Strapi 5 version before you enter a number. The value should come from a documented business need, such as the largest file editors legitimately publish. Restart Strapi, then sign in as an editor and upload a file just over the limit. The upload should be refused with a clear error, and a file just under the limit should succeed.

  3. Align the body parser limit at the server layer

    Strapi's body parser middleware, configured through the strapi::body entry in config/middlewares.js, sets its own ceiling on request bodies before the upload plugin runs. If that ceiling is lower than the upload plugin limit, valid files fail with a generic payload error. If it is much higher, the plugin check becomes the only control and oversized bodies still reach the application. Set the form and body limits so they match the upload limit plus a documented allowance for multipart overhead, and confirm the option names in the docs for your version. Done means a file just over the limit is rejected at the middleware with an error that your test plan expects.

  4. Match the reverse proxy and load balancer limits

    Nginx, a cloud load balancer, a CDN or a Kubernetes ingress controller may reject a request body before it reaches Strapi. In Nginx, the client_max_body_size directive controls this, and other layers have their own equivalents. Set every layer to the same maximum your Strapi configuration uses, and note the owner of each setting, since infrastructure teams often change these independently. Test through the public hostname, not an internal address, so the test follows the same path as real editors. Done means the same oversized file returns the same status code from the public endpoint as it does from Strapi directly.

  5. Remove upload permissions from unneeded roles

    In the admin panel, open Settings, then Users & Permissions, then Roles. Check the upload permissions for Public, Authenticated and each custom role, and clear any that the role does not need for its job. Anonymous visitors should not be able to upload under any configuration. Save each role, then confirm the change with a request made without a token. Done means an anonymous request to an upload endpoint is refused with an authentication or authorization error, and the Public role shows no upload actions.

  6. Configure the storage provider

    Choose an upload provider that stores files in object storage or another location outside the application server, then configure it in config/plugins.js. Confirm the provider package name, its required settings and its compatibility with your Strapi 5 version in the official documentation before installing it. Keep the storage credentials in your secrets store, not in the repository. Restrict the bucket or storage container so only the application identity can write to it. Done means a test upload appears in the storage location and no new file is written under the application's public uploads directory.

  7. Test rejection for each role

    Using a test account for each role from your inventory, send one undersized and one oversized file to every upload path. Record the status code, the response body and whether a file was stored. The results should match the expected outcome for each role: roles without upload rights are refused before the size check, and roles with upload rights are refused only when the file is too large. Keep the results with your change record so the next upgrade or permission change can be retested against the same matrix. Done means every cell in the matrix matches the expected result.

Why the size limit has to match every layer in front of Strapi

A file upload to Strapi passes several gates before the upload plugin ever sees it, and the strictest limit in the chain decides whether the request succeeds. The first gate is usually the reverse proxy or Kubernetes ingress, which often caps request body size by default. The second is the Node.js body parser inside the Strapi server, which enforces its own limit on multipart requests. The third is the upload plugin's sizeLimit setting, which is the value your editors think of as the policy. Setting the plugin to a generous value does nothing if the proxy rejects the body at a lower number, and raising the proxy limit does nothing if the body parser still refuses the request.

Mismatched limits produce confusing failures. Editors often see a generic error or a dropped connection rather than a clear message about file size, and the same file may succeed through one hostname and fail through another that sits behind a different proxy. To find the gate that rejected a request, start with the HTTP status code and response body, then check the proxy access and error logs for the same timestamp and request path. A rejection that appears in the proxy log but never reaches the Strapi log came from the proxy. A rejection that appears in Strapi's logs came from the application layer. Test with files just under and just over each candidate limit, and record which gate responded.

Before go-live, write down the intended maximum file size once and confirm the matching setting at each layer for your version. Confirm the exact configuration keys for the body parser and upload plugin in the Strapi documentation for your version, and check the proxy or ingress documentation for its body size directive or annotation, since names and defaults change between releases. Keep these values in the same configuration change so that a future edit to one layer does not silently break uploads in another.

How an upload request moves through the trust boundaries

The request starts at the client on the public internet and first meets the reverse proxy or ingress, which can reject oversized bodies before Strapi sees them. The request then crosses into the Strapi application, where the body parser limit and the upload permission check run before the upload plugin applies its own size and type checks. Accepted files go to local storage or an external provider, so confirm that each boundary enforces its own limit, since a limit set in only one layer leaves the others open.

Upload path from client to storage, with the proxy, application and storage trust boundaries shown.

Security risks to review in upload handling

Upload endpoints combine anonymous access, file handling and storage in one place, so a gap in any of them can expose data or capacity. The cards below cover the six risks to review in a Strapi project before go-live, with the control to verify for each.

Anonymous upload exposure

A Public role with the upload create permission lets any visitor send files to your media library without signing in. Check the Users & Permissions Public role for upload actions, then send a request with no token to confirm that the upload endpoint refuses it. Make sure only roles that need to upload hold that permission, and that upload routes are not exposed by accident through a custom permission.

Strapi SSO docs

Unrestricted file types

If the upload path accepts any file type, an attacker can store HTML, SVG or script-bearing files and have them served back from your domain. Define an allowlist of MIME types and extensions in your upload configuration and test it with a disallowed file. Confirm that files are served with a safe content type and that the uploads host is separated from the admin and API origin where possible.

Uploads on the application server disk

Storing uploads in the local public/uploads directory means every instance writes to its own disk, and a flood of large files can fill the volume that also holds logs, the database files and the application itself. Confirm the size limit, the volume capacity and where uploads land in each environment. Plan an external provider for multi-instance or high-volume setups.

Public bucket access on external storage

When uploads move to object storage, a bucket or container set to public read exposes every file, including drafts and private documents, to anyone who knows the URL. Check that the bucket is private by default, that the Strapi provider uses scoped credentials, and that public delivery is granted only to assets meant for the web. Confirm the credentials are not visible in the admin or the front end.

Metadata and malicious content

Images, PDFs and office files can carry embedded scripts, macros or metadata such as GPS coordinates and author names. Strapi does not inspect file contents for you by default, so decide whether files pass through a scanner or a sanitizing step before they are published. Test with a sample file that contains embedded metadata and confirm what is still present after upload.

Logs and retention of personal data

Uploaded files can contain personal data such as identity documents or health records, and that data can end up in backups, reverse proxy access logs or CDN caches. Document what each upload type may contain, set a retention rule for unused media and confirm that deletion in Strapi also removes the file from the storage provider. Check that logs record the request but not the file body.

When to move uploads off the application server

Move uploads off the application server once local disk stops being a safe place to keep files. By default, Strapi's upload provider writes files to the local public/uploads folder of the instance that received the request. That works for a single instance with a persistent volume and a reliable backup job. It breaks down in three situations: containers or hosts that are replaced on restart and lose unmounted files, several Strapi instances behind a load balancer where a file written by one instance is not visible to the others, and backup plans that cover the database but not the local folder, which leaves media files unrecoverable after a rebuild. If any of these apply to your deployment, plan the external provider before go-live rather than after editors have uploaded thousands of assets.

Access control is the other part of the decision. An external bucket lets you separate who can write, who can read and which networks may reach the storage, and you can apply those rules at the bucket level instead of relying only on Strapi's Upload plugin permissions. Ask your team to define which identities write objects (the Strapi process, usually through a dedicated service account with narrow write permissions), whether files are public or served through signed URLs, and how deletions are handled so that removing an entry in Strapi does not leave orphaned objects or accidentally remove a file still referenced elsewhere. Confirm the exact settings with your storage vendor and your provider's documentation.

Two related items belong on your checklist but are covered on sibling pages: the provider configuration itself and the content security policy needed for preview or media hosts. Before you commit, confirm that the provider plugin you intend to use is listed in the current Strapi documentation for your Strapi version, that it supports the upload size limits you set, and that its package name and configuration keys match the release you deploy. Plugin names and compatibility change between releases, so check them against current Strapi documentation rather than an older tutorial.

Questions teams ask about restricting Strapi uploads

What does it cost to restrict uploads in Strapi?

The cost depends on how much of the upload surface needs review, and no fixed price applies to every project. Effort rises with the number of upload paths (admin media library, content API endpoints, custom controllers), the storage provider and its signed-URL or CORS behavior, any custom validation you need, and the number of environments that must match. Most of the cost is one-time work to set limits, test them and document them, with a smaller recurring cost for re-checking after upgrades. Ask any vendor for a written quote that lists each upload path, each environment, the provider, and whether retesting is included.

What drives the effort up or down for an upload review?

Four factors matter most, and each one changes the work in a predictable way:

  • Number of upload paths: each custom route or plugin that accepts files needs its own testing.
  • Storage provider: moving files to object storage or a CDN adds configuration and access policy work.
  • Custom validation: file type checks, malware scanning hooks and content inspection are extra build and test effort.
  • Environments: development, staging and production must enforce the same limits, so each one needs verification.

A review with one upload path and one environment is far smaller than one spanning several custom endpoints across three environments.

How long does a Strapi upload restriction review take?

Duration depends on the number of upload paths, the environments under review and whether custom code must change, so no single figure applies to every system. A review that only confirms the built-in size limit and the admin role settings is short. Work that adds validation, moves storage or fixes custom controllers takes longer because each change needs a test pass. Ask for a timeline in the written scope, with milestones for discovery, changes, testing in each environment and handover.

What must our team provide before a review starts?

The reviewer needs enough context to test the real upload behavior, not a guess at it. Prepare these items:

  • The Strapi version and the installed plugins, including any upload provider.
  • The deployment topology: single host, containers, Kubernetes, and where the reverse proxy and load balancer sit.
  • The role model: which admin roles and Users & Permissions roles can create or update files.
  • The proxy configuration: body size limits at the reverse proxy and any timeouts that apply to uploads.
  • Access to non-production environments that mirror production settings.
Can one internal engineer restrict Strapi uploads alone?

An experienced Strapi engineer can make the core settings on their own, including the upload size limit and the body parser limit, provided they know where those settings live. The harder part is verification: testing uploads as each role, confirming the proxy and the application agree on limits, and checking that a storage provider enforces the same rules. Single-person work also creates a review gap, because the person who changed the setting is rarely the best person to test it. Many teams pair an internal owner with an outside tester or a second reviewer.

What changes after an upgrade to Strapi 5?

Upload behavior depends on the version, so restrictions tested on Strapi 4 must be checked again after the move. The Strapi v4 to v5 migration docs describe a codemod-based upgrade tool, data migration scripts that run on first start, and a breaking changes list that you should read before changing any settings. Strapi 4 reached end of life on April 30, 2026, so teams still on it should plan the move. Also confirm that the upload plugin, the body parser behavior and any custom controllers still apply the intended limits, and back up the database first because downgrading is not supported.

Does restricting uploads need a compliance review as well?

Upload controls often support compliance evidence, but they do not create compliance on their own. Regulated teams usually need documented settings, role assignments, test results and change records that an independent auditor can review. DeployOpen prepares systems, controls and evidence for compliance assessments, but it does not issue audit reports or certifications. Ask your assessor which evidence they expect before the work starts.

Limits to confirm in your environment

Upload size is enforced in more than one place, and each layer can stop a request before Strapi sees it. The cards below list the settings and components to confirm in the exact Strapi version and infrastructure you will run, so the limits you configure in the application are the limits that actually apply.

Strapi sizeLimit and body parser

Confirm the sizeLimit value that applies to uploads in your installed Strapi version, and the body parser limits that apply to JSON and form requests in the same project. Test with files just under and just over the limit, and confirm the rejection status and message. Check the setting in the configuration files of the built project, not only in the source you deployed from, because a value set only in one environment can be missed in another.

Strapi installation docs

Reverse proxy and CDN limits

A reverse proxy, ingress controller or CDN may reject large bodies before Strapi runs, and the rejection may look like an application error. List every hop between the browser and the Strapi process, and confirm the maximum request body size at each one. Align those values with the Strapi limit so a user never sees a proxy error for a file the application accepts, or the reverse.

Upload provider file type checks

Confirm whether your chosen upload provider validates file types, extensions or content signatures, or whether Strapi and the provider accept any file. Do not assume that a MIME type sent by the browser is accurate. Ask the provider vendor which checks it performs, and test an executable or script renamed with an image extension to see what is stored and how it is served.

Multipart uploads through the load balancer

Large multipart uploads can fail or time out when a load balancer buffers, idles or splits connections differently from the application. Confirm the request timeout, buffering behavior and sticky session settings for the upload path, and test an upload through the same balancer used in production. Many failures appear only under real network conditions, so run the test from outside the internal network.

Node.js and database versions

Strapi runs only on Active or Maintenance LTS Node.js versions, and it supports specific database versions. Confirm the Node.js version, PostgreSQL, MySQL, MariaDB or SQLite version against the Strapi installation requirements for the release you are deploying. Upload metadata is stored in the database, so an unsupported database version can cause failures that look like upload faults.

Minimum PostgreSQL
14
Installation requirements

Enterprise audit trail needs

If the organization must record who uploaded or deleted a file, confirm whether the Community Edition meets that need or whether audit logs, which are an Enterprise feature, are required. Ask your procurement and compliance teams to define the evidence they need, then compare it with the plan you select. Include this in the quote request so the scope and licensing are agreed before build begins.

Self-hosted plans

What a DeployOpen review of upload settings covers

A DeployOpen review of upload settings is a fixed-scope engagement, and its first step is an inventory of every path that can accept a file into a Strapi project. That means the admin panel media library, the Content API routes that receive multipart requests from custom controllers, any custom upload endpoints, and the upload provider configured in the project. For each path, the review records who can reach it (the Public role, authenticated end users, API tokens and editors), what it accepts, and where the bytes end up. Most findings come from this inventory, because a limit set in one place does not protect a route that bypasses it.

Next comes the change set. Configuration changes are made in the client's own repository, not on a running server, so they are reviewed, versioned and deployable with the rest of the project. Typical changes touch the sizeLimit value in the upload plugin configuration, the body parser limits in the server middleware, the Users & Permissions permissions for upload actions, and the provider settings that decide whether files are stored on the application server or in external object storage. Where a size or type rule belongs in custom code, the change is scoped to that route and documented alongside the configuration.

The engagement closes with test cases and handover notes. Test cases cover oversize files, requests just under and just over the configured limit, anonymous and authenticated uploads, token-based uploads, and confirmation that rejected files are not written to storage. Handover notes explain each setting, why it was chosen, how to change it safely and which checks to repeat after an upgrade. Scope, deliverables, retest expectations and any environments in scope are agreed in writing before work starts, and a quote follows from that written scope. Ask for the test matrix and the list of repository files that will change before you sign.

How DeployOpen scopes and supports Strapi upload controls

DeployOpen approaches upload restrictions in Strapi as part of a written, fixed-scope engagement covering the size limits, permissions, and storage location for your files. The work is planned against your Strapi version, hosting model, and compliance requirements, then tested and handed over with documentation your team can run.

How we scope

  • Inventory every content type, component, and upload field that accepts files, with the editors and API clients who submit them.
  • Agree the maximum file sizes, permitted file types, and which roles may upload, in writing before build begins.
  • Confirm the hosting model, reverse proxy, and object storage target so body parser and provider limits are set consistently.

How we build

  • Configure the sizeLimit setting and body parser limits in the Strapi project, then align them with the reverse proxy request size.
  • Restrict upload permissions in the Users & Permissions and admin roles so only approved accounts can create media.
  • Move file storage to your chosen provider or object store so application servers do not hold uploaded content long term.

How we hand over

  • Test oversize, disallowed, and anonymous upload attempts and record the results against the agreed scope.
  • Document each limit, its location in configuration, and the steps to change it safely during future releases.
  • Provide a retest after fixes so your security and platform teams can confirm the controls behave as written.

How we support

  • Review upload settings again when you upgrade Strapi, since defaults and plugin behavior can change between releases.
  • Offer ongoing support, upgrades, and continuous testing as a retainer, scoped separately from the initial engagement.
  • Confirm with your own environment and provider documentation which limits apply at each layer before go-live.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.