Dev.to Security 🔐 Cybersecurity 👁 0 📖 5 min read

Selecting Object Storage APIs for Direct Browser Artifact Intake Under Tenant Retention

Short answer: choose an object-storage upload API that lets your application mint short-lived, object-specific upload authority, enforce tenant-scoped keys, validate metadata after upload, and apply retention from immuta

Short answer: choose an object-storage upload API that lets your application mint short-lived, object-specific upload authority, enforce tenant-scoped keys, validate metadata after upload, and apply retention from immutable artifact facts. The browser should never decide the tenant, final object name, retention class, or authorization boundary.

The page that matters is usually the one that arrives later: a training job cannot find an artifact, or a tenant can see a neighboring tenant's file. By then, the upload request finished successfully. The useful design work happened before that green response.

How should I select a storage API for direct browser uploads?

For an e-commerce training pipeline, I would start with an artifact record owned by the application database. It contains a tenant ID, a server-generated artifact ID, the expected byte limit, a content digest when available, the policy version, and the retention decision. The browser receives permission for one object and one bounded operation. It does not receive a general storage credential.

The object key should be derived from trusted fields, for example tenant/{tenantID}/training/{artifactID}/payload. Do not accept a browser-supplied tenant prefix and try to sanitize it later. Path cleanup does not establish authorization. The upload service must check the authenticated subject's tenant membership, then create the key itself.

A presigned request is a capability, not proof that the bytes are good. Keep its lifetime short enough to limit reuse, bind it to the intended method and object, and record its issuance. On completion, inspect the stored object's size, media type, checksum, and metadata. Mark the database record ready only after those checks pass.

Which failure should wake the on-call first?

A successful upload count is a weak signal. It says the transport worked, not that the training system can safely consume the artifact. The earlier signal is a growing gap between issued upload capabilities and verified artifact records. The later page is a retention or processing miss.

I would emit counters for capabilities issued, uploads completed, verification failures, and records that remain pending past a bounded interval. Keep tenant identity as a controlled dimension, not an unbounded label copied from a request. An alert can then distinguish a single tenant's bad client from a platform-wide verification problem.

The threshold has a cost on both sides. Page on every failed upload and normal mobile retries become an incident. Page only on missing training artifacts and a bad key derivation can hide until the next batch. The runbook should inspect the artifact ID, policy version, and verification reason, while redacting object names if they can contain customer data.

The first question is ownership.

How do retention rules stay reproducible across tenants?

Do not calculate expiry from the browser timestamp. At artifact creation, persist the policy version and the server-side creation time that drove the decision. A policy change can affect future artifacts without silently rewriting the meaning of old ones. The retention worker reads those stored facts and records its decision.

That gives operators an audit trail: who authorized the upload, which tenant owned it, which policy version applied, when verification completed, and when deletion became eligible. Deletion should be idempotent. A retry after a timeout must converge on the same state instead of creating a second artifact or turning an already-completed deletion into a fatal error.

Here is the shape of a small policy boundary. It is deliberately independent of a storage vendor's SDK:

package retention

import "time"

type Artifact struct {
    TenantID  string
    CreatedAt time.Time
    PolicyVer string
    Retention time.Duration
    Verified  bool
}

func ExpiresAt(a Artifact) time.Time {
    return a.CreatedAt.Add(a.Retention)
}

The duration is not magic configuration hidden in a worker. It is a value resolved by a versioned policy service and persisted with the artifact. That distinction is what makes a replay explainable six months later.

A practical decision rule for object-storage APIs

Evaluate the API at the boundary where an untrusted browser becomes a durable object. I would require these properties before looking at throughput or convenience:

  • Per-object, short-lived authorization that the application can mint after tenant checks.
  • Conditions or equivalent controls for method, object identity, size, and required metadata.
  • A post-upload inspection path that exposes enough information to verify the database record.
  • Checksums and an explicit multipart-upload lifecycle, including how abandoned parts are found.
  • Audit events that can be correlated with an artifact ID without logging secrets.
  • A documented isolation model for prefixes, policies, accounts, and cross-tenant reads.

The API can satisfy those requirements through different protocol shapes. That is fine. The selection fails when a convenient browser SDK makes authorization implicit, when an upload completion response is treated as validation, or when retention exists only as a bucket-wide setting.

Upload approach Strength Limitation Best fit
Short-lived direct object upload Keeps application servers out of the byte path Requires careful capability issuance and post-upload verification Large training artifacts with a trusted control plane
Application-proxied upload Centralizes validation before storage Adds a bandwidth and scaling boundary in the application tier Small files or strict inline inspection
Multipart direct upload Handles interrupted transfers and large objects Leaves more lifecycle state to reconcile and clean up Large files where resume matters

That is the trade-off I want recorded in a design review. Direct upload is not automatically more secure; it is secure only when the control plane remains authoritative. A proxy is not automatically safer either, because a permissive application endpoint can still accept the wrong tenant's object.

The browser is an untrusted transport.

My runbook starts with a six-case matrix: tenant A's capability against tenant B's key, an oversized body, a changed content type, a replayed capability, an interrupted multipart upload, and a retry after verification timeout. Each case should leave an auditable state.

A green browser response is not enough.

Further reading

📰 Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.