Claude Cursor GitHub Copilot Skill

frontend-bff-boundary-review

Determines and reviews whether aggregation/shaping logic belongs in a Backend-for-Frontend layer versus client-side composition, and audits existing BFF boundaries for scope creep, duplicated aggregation logic, and leaked backend topology or pass-through authorization.

LLM Mart · 0 points · 0 views 0 listing impressions 0 install-command copies
Virus-scanned Reviewed automatically before listing.

Full trust report

Download vincentchuwaichow-vanguard-frontier-agentic-skills_frontend_frontend-bff-boundary-review-febe32a.zip · 10 KB
Part of vincentchuwaichow/vanguard-frontier-agentic — 293 skills

Install

skills CLI npx skills add https://github.com/VincentChuWaiChow/vanguard-frontier-agentic/tree/master/skills/frontend/frontend-bff-boundary-review
Claude Code claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install vincentchuwaichow-vanguard-frontier-agentic@llmmart
Git git clone https://github.com/VincentChuWaiChow/vanguard-frontier-agentic.git

The skills CLI installs just this skill, for any of its supported agents. Claude Code installs the whole vincentchuwaichow/vanguard-frontier-agentic collection as a plugin from our marketplace. Git is the plain clone.

Skill manifest

Frontend BFF Boundary Review

Purpose

Decide whether a multi-backend data need belongs in a Backend-for-Frontend (BFF) route or in client-side composition, and audit an existing BFF layer for the two failure modes that matter most: organic scope creep (duplicated or one-off aggregation logic scattered across routes) and trust-boundary erosion (a BFF that forwards client-supplied authorization claims or credentials without re-verifying them, or that leaks internal backend topology into its responses). This skill exists so the boundary decision and the trust-boundary audit stay the focus, and so field-level contract review of an already-scoped endpoint, or client-side cache/store design once data has landed in the browser, stay out of scope.

When to use

Use this skill when the user asks to:

  • decide whether a feature needing data from multiple backend services should aggregate server-side (a BFF route) or client-side (parallel query-library calls),
  • audit an existing BFF layer, or a specific BFF route, that has grown organically over time,
  • review whether a proposed new BFF route or service duplicates an existing one's aggregation logic,
  • check whether a BFF route re-authenticates/re-authorizes the caller or merely passes through client-supplied claims/tokens to backend services.

Do not use this skill for:

  • reviewing the field-level shape, versioning, or authorization contract of a single already-scoped API endpoint — that is api-integration-contract-review,
  • client-side cache/store design (query-library cache keys, state colocation) once data has already been fetched — that is state-management-decision-review,
  • rendering-mode or fetch() cache-directive selection for a Next.js route with no cross-service aggregation involved — that is nextjs-rendering-caching-review,
  • Server Action authorization or 'use client'/'use server' boundary review with no BFF-scope question involved — that is nextjs-app-router-data-fetching-review.

Context7 Documentation Protocol

  • Resolve /vercel/next.js with resolve-library-id before citing any Route Handler capability, caching directive, or runtime behavior as grounds for a BFF-vs-client-composition recommendation.
  • Before recommending a Next.js Route Handler as the BFF implementation vehicle, read the repo's package.json to confirm the installed Next.js major version, then call query-docs scoped to that version for "Route Handler caching" and "route segment config revalidate fetchCache." Caching semantics changed materially across major versions — Route Handler GET methods are cached by default through Next.js 14 but are not cached by default starting in Next.js 15, requiring an explicit export const dynamic = 'force-static' to opt back in. A BFF route assumed to cache aggregated responses on an unverified version can silently hit every backend on every request instead of reducing round-trips as intended.
  • If the version cannot be confirmed, or Context7 is unavailable, state the caching claim as documentation-based, version-unconfirmed and recommend the user verify export const dynamic / export const revalidate / export const fetchCache behavior against their installed version before relying on it for load-reduction claims.
  • Do not assume a Route Handler behaves like a fetch() call inside a Server Component; segment-level config (dynamic, revalidate, fetchCache) governs the Route Handler's own caching, and it is set independently of caching used for calls the handler itself makes.

Lean operating rules

  • A BFF is a trust boundary, not a convenience layer for reshaping JSON. The default posture for any BFF route is that it terminates the client's authentication context and establishes its own — it does not relay whatever the client sent forward.
  • Default toward BFF aggregation when a feature needs data from two or more backend services with different authorization models or error shapes. Default toward client-side composition only when the backends involved are already safe to call directly from the browser (same trust level as the client, already CORS-exposed, no internal-only topology).
  • Before proposing a new BFF route, search for an existing route already serving an overlapping need. A second BFF route re-implementing the same aggregation is a maintenance and drift risk, not a fresh feature.
  • Treat any BFF route that reads a client-supplied authorization claim (a role, user ID, or permission flag taken from a request body, query string, or an unverified header) and uses it directly to gate a backend call as a HIGH-severity finding — this is pass-through authorization, not delegation.
  • Treat any BFF route that forwards a client-supplied bearer token or credential straight to a downstream backend, in place of the BFF re-authenticating the session and minting its own downstream credential, as a HIGH-severity finding, unless the system is an explicit, documented token-exchange/delegation design (e.g. OAuth token exchange) with its own re-verification step.
  • Treat any BFF response that exposes internal-only backend hostnames, service names, stack traces, or service-specific error codes/shapes verbatim to the browser as a MEDIUM-to-HIGH finding depending on sensitivity — the BFF exists in part to prevent this leak, and a thin pass-through response defeats that purpose.
  • Do not recommend client-side composition when it would require the browser to hold credentials for, or make direct network calls to, a backend that is not already intended to be internet-reachable — that is a bigger security regression than the aggregation-placement question being asked.
  • Do not flag every multi-call client-side data-fetching pattern as a problem. Client-side composition of two or three already-public, already-authorized endpoints is a legitimate, lower-latency choice; only escalate when trust boundaries or topology are actually crossed.
  • Never execute, build, or run application code as part of this review; this is a static-review skill (Read/Grep/Glob only).
  • Treat any hardcoded API key, service token, or credential found in BFF route source, environment file references, or example data as a HIGH-severity finding requiring immediate escalation, separate from the boundary-scope verdict.

References

Load these only when needed:

Response minimum

Return, at minimum:

  • the boundary decision (BFF aggregation vs. client-side composition) with justification tied to the number of backends, their auth models, and their reachability from the browser,
  • for any new/extended BFF route: an explicit scope statement and a check for an existing overlapping route,
  • a trust-boundary audit result (pass-through-authorization check, credential-forwarding check, topology-leak check) for any BFF route in scope,
  • ranked findings with file:line evidence, risk class, and fix,
  • the Next.js major version the caching claims were verified against, if a Route Handler is the proposed implementation,
  • verdict: approve / approve-with-notes / block,
  • evidence level and open questions.
Files (vanguard-frontier-agentic)
  • references
    • owasp-api-trust-boundary.md 5.8 KB
      # OWASP API Security — trust-boundary risks
      
      Use this reference only when a BFF pass-through-authorization, credential-forwarding, or topology-leak finding is present, to ground the finding's OWASP API Security Top 10 classification and severity framing. Do not load this for placement-decision-only or duplication-only findings.
      
      ## What people get wrong
      
      The naive story is:
      
      > The BFF sits on the server, so anything it does is "backend" and therefore trusted. If the client already sent a valid-looking token or role claim, the BFF can just pass it along to keep things simple.
      
      That confuses **where the BFF runs** with **what it verifies**. A BFF's value as a trust boundary comes entirely from the fact that it terminates the client's untrusted request and re-establishes a verified identity before talking to backends that may extend it a higher level of implicit trust (network-level trust, service credentials, mTLS). A BFF that relays a client-supplied claim or token unmodified has not added a trust boundary — it has added a network hop that carries the exact same unverified trust forward, while looking, to anyone reading the architecture diagram, like a security control exists there.
      
      ## Why this maps to the OWASP API Security Top 10, not a generic bug
      
      The OWASP API Security Top 10 exists because API-shaped systems fail differently from traditional web apps — trust decisions happen at machine-to-machine boundaries with no UI to visually obscure the shortcut. The BFF failure modes in this skill's scope map onto specific categories:
      
      - **Pass-through authorization** — the BFF reads a role, permission flag, or user identifier directly from client-supplied input (a header, body field, or query parameter) and uses it to gate a backend call, instead of re-deriving that identity from its own verified session. This is a **Broken Object Property Level Authorization / Broken Function Level Authorization** failure: the client dictates its own privilege level, and the BFF enforces nothing.
      - **Credential forwarding** — the BFF forwards a client-supplied bearer token, API key, or session artifact straight to a downstream backend instead of re-authenticating and minting its own downstream credential scoped to the verified identity. This is a **Broken Authentication** failure at the BFF layer: the BFF has no authentication step of its own, it is a transparent relay wearing an authentication-shaped label.
      - **Topology leakage** — the BFF's responses or error handling expose internal-only backend hostnames, service names, or backend-specific error codes/shapes verbatim to the client. This is a **Security Misconfiguration / excessive data exposure** failure: the BFF's shaping responsibility — the entire reason to interpose a server-side layer instead of letting the client call backends directly — has been skipped, and the client now has a map of internal architecture it should never see.
      
      All three are trust-boundary defects, not merely "missing error handling" or "verbose logging" — the defect is that a boundary presented as a security control performs none of the verification or shaping that justifies calling it one.
      
      ## Non-negotiable framing rules
      
      - **Severity floor**: pass-through authorization and credential forwarding are HIGH severity, regardless of how the client-supplied value was obtained (even if it originated from a legitimate prior login) — the defect is that the BFF trusts it without independent verification. Topology leakage is MEDIUM-to-HIGH depending on the sensitivity of what leaked (an internal hostname is lower severity than a leaked service-account error revealing valid credentials or query structure).
      - **Evidence requirement**: cite the exact client-controlled value (header name, body field, query param) the BFF trusts in place of its own verification, or the exact response/error path that exposes internal topology.
      - **Do not conflate with input validation**: a BFF route that fails to validate the *shape* of a request body is a data-integrity note, not a trust-boundary finding by itself. These categories apply specifically to authorization/authentication *decisions* and *response shaping*, not to whether input is well-formed.
      - **Token-exchange is not automatically a defect**: a BFF that receives a client token and performs an explicit, documented token-exchange step (validating the client token, then requesting a new downstream-scoped token from an authorization server) is re-verifying, not passing through. The distinguishing question is always: did the BFF perform its own verification step, or did it just relay the value forward unchanged?
      
      ## Minimal safe fix pattern
      
      Every HIGH finding from this reference should point toward the same shape of fix: the BFF independently verifies the caller (session validation, token introspection, or a documented token-exchange call) and derives the identity/role used for backend authorization from that verification step — never from a value the client attached to the request. For topology leakage, the fix is a response-shaping layer that maps backend-specific errors to a generic, client-safe error taxonomy before the response leaves the BFF.
      
      ## When to push back
      
      Push back if the user proposes:
      
      - "the token was already validated on the frontend, so the BFF doesn't need to check it again" — reject; frontend validation is not enforceable and does not constitute a server-side trust boundary.
      - "we'll just forward the Authorization header, it's simpler than minting a new one" — reject unless this is an explicit, documented token-exchange design with its own verification step, not a bare relay.
      - "the error message is only useful for debugging, it's fine if it shows the service name" — reject; a debugging convenience shipped to production clients is exactly the kind of topology leak this reference exists to catch.
      
      Those are not shortcuts. They are the exact failure mode this reference exists to catch.
      
    • workflow-and-output.md 10.3 KB
      # Review workflow and findings contract
      
      Use this reference for the full boundary-decision procedure, the existing-BFF audit method, and the required output shape.
      
      ## What people get wrong
      
      The naive story is:
      
      > A BFF is just a place to smoosh a couple of API responses together before sending them to the client. If the client is already logged in, the BFF can just pass that along.
      
      Wrong, on both halves.
      
      - **Aggregation-placement is not a style preference.** Whether a need should be solved server-side (BFF) or client-side (parallel calls from the browser) is a trust-boundary and topology question first, and a latency/convenience question second. Getting it backward either forces the browser to hold credentials for internal-only services, or grows a BFF into an unbounded pile of feature-specific routes with no consolidation.
      - **"The client is logged in" is not the same as "the BFF has verified this request."** A BFF sits between an untrusted client and one or more backends that may trust the BFF implicitly (mTLS, network-level trust, service credentials). If the BFF forwards a client-supplied claim or token instead of re-establishing its own trusted identity for the call, it has not added a trust boundary — it has just added a network hop with the same trust problem.
      
      The review has to operate at two levels: the **placement decision** (should this be a BFF route or client composition, and does a route already exist for this need) and the **trust-boundary audit** (does the BFF re-verify, or does it pass through) — and a clean placement decision does not excuse a failed trust-boundary audit, or vice versa.
      
      ## Workflow — new aggregation need (placement decision)
      
      1. **Enumerate the backends the feature needs data from.**
         - List each backend service, its authorization model (session cookie, API key, mTLS, service token), and its current reachability from the browser (already CORS-exposed and public, or internal-only).
      
      2. **Apply the default-toward-BFF test.**
         - Two or more backends with different auth models or error shapes → default toward BFF aggregation.
         - All backends are already browser-reachable, already public, and share a trust level with the client → client-side composition is a legitimate option.
         - Any backend involved is internal-only and not intended to be browser-reachable → BFF aggregation is required; client-side composition would mean exposing that backend directly, which is a bigger regression than the placement question itself.
      
      3. **Search for an existing BFF route covering an overlapping need.**
         - Grep the BFF/route-handler directory for routes touching the same backend services or a similar response shape. A new route that re-implements existing aggregation logic instead of extending it is a duplication finding, not a placement finding — call it out separately.
      
      4. **If a Route Handler is the proposed implementation, confirm the Next.js major version before making caching claims.**
         - See the Context7 Documentation Protocol in SKILL.md. Route Handler `GET` caching defaults changed between Next.js 14 and 15; do not claim a BFF route "reduces backend load through caching" without confirming the version and the explicit `dynamic`/`revalidate`/`fetchCache` configuration in the route itself.
      
      ## Workflow — existing BFF audit (trust-boundary + scope audit)
      
      1. **Enumerate every BFF route in scope.**
         - For each, identify: which backend(s) it calls, what authorization input it uses to gate each backend call, and what shape it returns to the client.
      
      2. **Classify each route's authorization source.**
         - **Re-authenticated (correct):** the route derives the caller's identity from a server-side session/auth mechanism the BFF itself verifies (a validated session cookie, a re-issued short-lived downstream token minted by the BFF after its own verification), independent of any claim the client attached to the request body or headers.
         - **Pass-through (defect):** the route reads a role, user ID, permission flag, or `Authorization` bearer value directly from the incoming client request and forwards it — or a value derived from it — to a backend call without the BFF independently verifying it first.
         - **Missing (defect):** the route makes an authorization-sensitive backend call with no authorization check at all in the BFF layer, relying solely on the backend to reject unauthorized calls (which, if the backend trusts the BFF network-level, means the backend performs no check either).
      
      3. **Check for topology leakage in each route's response and error handling.**
         - Does an error response include a backend hostname, internal service name, stack trace, or backend-specific error code/shape passed through verbatim? If the client can distinguish "billing-service returned 503" from "usage-service returned 500," the BFF is not shaping the response, it is proxying it.
      
      4. **Check for duplicated or drifted aggregation logic across routes.**
         - If two or more BFF routes independently implement near-identical aggregation of the same backends (with copy-pasted or subtly diverging logic), flag it as a maintenance/drift finding — the fix is consolidation, not a rewrite of either route in isolation.
      
      5. **Produce ranked findings.**
         - Order by blast radius: pass-through authorization and credential-forwarding findings first (HIGH), then topology leakage (MEDIUM/HIGH depending on sensitivity of what leaked), then missing-consolidation/duplication findings (MEDIUM/LOW).
      
      ## Decision tree
      
      - Feature needs data from 2+ backends with different auth models or error shapes → **BFF aggregation required.** Check for an existing overlapping route before creating a new one.
      - An existing BFF route already covers this need → **extend it; do not create a duplicate.**
      - Client-side composition would require the browser to hold credentials for, or call directly, an internal-only backend → **block; require BFF aggregation.**
      - A BFF route reads a client-supplied authorization claim and uses it directly to gate a backend call → **HIGH: pass-through authorization.** Load `references/owasp-api-trust-boundary.md` and frame the finding per that reference.
      - A BFF route forwards a client-supplied bearer token/credential straight to a backend instead of re-authenticating and minting its own downstream credential (and this is not an explicitly documented token-exchange design) → **HIGH: credential pass-through.**
      - A BFF response exposes internal-only hostnames, service names, or backend-specific error shapes to the client → **MEDIUM-to-HIGH: topology leak,** severity scaled by sensitivity of what is exposed.
      - Two or more BFF routes independently re-implement the same aggregation → **MEDIUM: duplicated aggregation logic; recommend consolidation.**
      
      ## Output contract
      
      Return:
      
      1. Boundary decision: BFF aggregation or client-side composition, with the backend count/auth-model/reachability reasoning that drove it
      2. For new/extended BFF routes: scope statement and result of the existing-route overlap search
      3. Per-route trust-boundary table (for audits): route | authorization source (re-authenticated / pass-through / missing) | credential-forwarding check | topology-leak check
      4. Ranked findings, each with:
         - file:line evidence
         - risk class (pass-through-authorization / credential-forwarding / topology-leak / duplicated-aggregation)
         - concrete fix, scoped to the narrowest sufficient change
         - severity (HIGH / MEDIUM / LOW)
         - evidence level (`repo evidence`, `documentation-based`, `inference`)
      5. Next.js major version confirmed, if a Route Handler is the proposed or reviewed implementation, or explicitly noted as unconfirmed
      6. Verdict: approve / approve-with-notes / block
      7. Open questions or explicitly out-of-scope items (e.g. field-level contract details deferred to `api-integration-contract-review`, client-side cache design deferred to `state-management-decision-review`)
      
      ## Validation gates
      
      - No duplicated BFF aggregation logic for the same need is approved without a consolidation recommendation.
      - Every pass-through-authorization finding identifies exactly which client-supplied value (header, body field, query param) is being trusted in place of BFF-side re-verification.
      - No BFF route that exposes an internal-only backend's hostname or service-specific error shape verbatim is approved without a topology-leak finding.
      - No new BFF route is approved without first checking for an existing overlapping route.
      - No finding is downgraded to a style note for "it's just an internal tool" reasoning — the security-notes hard gate in `metadata.json` applies regardless of perceived internal-only exposure, since internal-only assumptions are exactly what erode over a system's lifetime.
      
      ## Common failure modes
      
      - Treating "the BFF runs on the server" as sufficient trust justification, without checking whether it actually re-verifies the caller or just relays what it received.
      - Approving a new BFF route without grepping for an existing route already covering the same backend combination.
      - Letting error responses pass through backend-specific shapes/codes/hostnames unshaped, because "it's easier to just forward the error."
      - Recommending client-side composition to "keep it simple" when one of the backends involved is not meant to be browser-reachable.
      - Missing that two BFF routes have quietly diverged while implementing nominally the same aggregation, because each was reviewed in isolation.
      
      ## Adversarial checklist
      
      Before finalizing a finding, answer these:
      
      - Does this BFF route re-verify the caller's identity itself, or does it just forward whatever authorization claim/token the client attached?
      - Is there already a BFF route serving this need that should be extended instead of duplicated?
      - Does the route's response or error handling leak an internal backend hostname, service name, or service-specific error shape?
      - Would client-side composition require exposing an internal-only backend directly to the browser?
      - Is this aggregation logic duplicated, with possible drift, across more than one BFF route?
      - If a Route Handler caching claim is being made, has the Next.js major version actually been confirmed rather than assumed?
      
      If any answer is "not sure," lower the finding's confidence and label the evidence level accordingly — do not present it as a confirmed defect, except for pass-through-authorization and credential-forwarding findings with clear file:line evidence, which stay HIGH regardless.
      
  • metadata.json 1.7 KB
    {
      "id": "frontend-bff-boundary-review",
      "name": "Frontend BFF Boundary Review",
      "type": "skill",
      "provider": "frontend",
      "harnesses": [
        "claude-code",
        "cursor",
        "codex",
        "gemini",
        "kiro",
        "other"
      ],
      "summary": "Determines and reviews whether aggregation/shaping logic belongs in a Backend-for-Frontend layer versus client-side composition, and audits existing BFF boundaries for scope creep, duplicated aggregation logic, and leaked backend topology or pass-through authorization, grounded via Context7 against the repo's confirmed Next.js version when a Route Handler is the proposed BFF vehicle.",
      "source_type": "original",
      "official_docs": [
        "https://nextjs.org/docs/app/building-your-application/routing/route-handlers",
        "https://nextjs.org/docs/app/building-your-application/caching",
        "https://owasp.org/www-project-api-security/"
      ],
      "security_notes": "A BFF is a trust boundary, not just a convenience layer — flag any BFF route that passes through client-supplied authorization claims unchecked, or that forwards credentials/tokens client-to-backend without the BFF itself re-authenticating the session, as a HIGH-severity finding. A BFF response that exposes internal-only backend hostnames, service names, or service-specific error shapes verbatim to the browser is a topology-leak finding. Static-review-only skill: it reads and greps BFF route source and does not execute, build, or run application code. Treat any hardcoded API key, service token, or credential found in route source as a HIGH-severity finding requiring immediate escalation.",
      "last_verified": "2026-07-02",
      "path": "skills/frontend/frontend-bff-boundary-review",
      "author": "github: VincentChuWaiChow",
      "version": "0.1.0"
    }
    
  • SKILL.md 7.9 KB
    ---
    name: frontend-bff-boundary-review
    description: Determines and reviews whether aggregation/shaping logic belongs in a Backend-for-Frontend layer versus client-side composition, and audits existing BFF boundaries for scope creep, duplicated aggregation logic, and leaked backend topology or pass-through authorization.
    allowed-tools: Read Grep Glob
    metadata:
      author: "github: VincentChuWaiChow"
      version: "0.1.0"
      updated: "2026-07-02"
      category: architecture
    ---
    
    # Frontend BFF Boundary Review
    
    ## Purpose
    
    Decide whether a multi-backend data need belongs in a Backend-for-Frontend (BFF) route or in client-side composition, and audit an existing BFF layer for the two failure modes that matter most: organic scope creep (duplicated or one-off aggregation logic scattered across routes) and trust-boundary erosion (a BFF that forwards client-supplied authorization claims or credentials without re-verifying them, or that leaks internal backend topology into its responses). This skill exists so the boundary decision and the trust-boundary audit stay the focus, and so field-level contract review of an already-scoped endpoint, or client-side cache/store design once data has landed in the browser, stay out of scope.
    
    ## When to use
    
    Use this skill when the user asks to:
    
    - decide whether a feature needing data from multiple backend services should aggregate server-side (a BFF route) or client-side (parallel query-library calls),
    - audit an existing BFF layer, or a specific BFF route, that has grown organically over time,
    - review whether a proposed new BFF route or service duplicates an existing one's aggregation logic,
    - check whether a BFF route re-authenticates/re-authorizes the caller or merely passes through client-supplied claims/tokens to backend services.
    
    Do not use this skill for:
    
    - reviewing the field-level shape, versioning, or authorization contract of a single already-scoped API endpoint — that is `api-integration-contract-review`,
    - client-side cache/store design (query-library cache keys, state colocation) once data has already been fetched — that is `state-management-decision-review`,
    - rendering-mode or `fetch()` cache-directive selection for a Next.js route with no cross-service aggregation involved — that is `nextjs-rendering-caching-review`,
    - Server Action authorization or `'use client'`/`'use server'` boundary review with no BFF-scope question involved — that is `nextjs-app-router-data-fetching-review`.
    
    ## Context7 Documentation Protocol
    
    - Resolve `/vercel/next.js` with `resolve-library-id` before citing any Route Handler capability, caching directive, or runtime behavior as grounds for a BFF-vs-client-composition recommendation.
    - Before recommending a Next.js Route Handler as the BFF implementation vehicle, read the repo's `package.json` to confirm the installed Next.js major version, then call `query-docs` scoped to that version for "Route Handler caching" and "route segment config revalidate fetchCache." Caching semantics changed materially across major versions — Route Handler `GET` methods are cached by default through Next.js 14 but are **not** cached by default starting in Next.js 15, requiring an explicit `export const dynamic = 'force-static'` to opt back in. A BFF route assumed to cache aggregated responses on an unverified version can silently hit every backend on every request instead of reducing round-trips as intended.
    - If the version cannot be confirmed, or Context7 is unavailable, state the caching claim as `documentation-based, version-unconfirmed` and recommend the user verify `export const dynamic` / `export const revalidate` / `export const fetchCache` behavior against their installed version before relying on it for load-reduction claims.
    - Do not assume a Route Handler behaves like a `fetch()` call inside a Server Component; segment-level config (`dynamic`, `revalidate`, `fetchCache`) governs the Route Handler's own caching, and it is set independently of caching used for calls the handler itself makes.
    
    ## Lean operating rules
    
    - A BFF is a trust boundary, not a convenience layer for reshaping JSON. The default posture for any BFF route is that it terminates the client's authentication context and establishes its own — it does not relay whatever the client sent forward.
    - Default toward BFF aggregation when a feature needs data from two or more backend services with different authorization models or error shapes. Default toward client-side composition only when the backends involved are already safe to call directly from the browser (same trust level as the client, already CORS-exposed, no internal-only topology).
    - Before proposing a new BFF route, search for an existing route already serving an overlapping need. A second BFF route re-implementing the same aggregation is a maintenance and drift risk, not a fresh feature.
    - Treat any BFF route that reads a client-supplied authorization claim (a role, user ID, or permission flag taken from a request body, query string, or an unverified header) and uses it directly to gate a backend call as a HIGH-severity finding — this is pass-through authorization, not delegation.
    - Treat any BFF route that forwards a client-supplied bearer token or credential straight to a downstream backend, in place of the BFF re-authenticating the session and minting its own downstream credential, as a HIGH-severity finding, unless the system is an explicit, documented token-exchange/delegation design (e.g. OAuth token exchange) with its own re-verification step.
    - Treat any BFF response that exposes internal-only backend hostnames, service names, stack traces, or service-specific error codes/shapes verbatim to the browser as a MEDIUM-to-HIGH finding depending on sensitivity — the BFF exists in part to prevent this leak, and a thin pass-through response defeats that purpose.
    - Do not recommend client-side composition when it would require the browser to hold credentials for, or make direct network calls to, a backend that is not already intended to be internet-reachable — that is a bigger security regression than the aggregation-placement question being asked.
    - Do not flag every multi-call client-side data-fetching pattern as a problem. Client-side composition of two or three already-public, already-authorized endpoints is a legitimate, lower-latency choice; only escalate when trust boundaries or topology are actually crossed.
    - Never execute, build, or run application code as part of this review; this is a static-review skill (Read/Grep/Glob only).
    - Treat any hardcoded API key, service token, or credential found in BFF route source, environment file references, or example data as a HIGH-severity finding requiring immediate escalation, separate from the boundary-scope verdict.
    
    ## References
    
    Load these only when needed:
    
    - [Review workflow and findings contract](references/workflow-and-output.md) — use for the step-by-step boundary-decision procedure, the existing-BFF audit method, and the required output shape.
    - [OWASP API Security — trust-boundary risks](references/owasp-api-trust-boundary.md) — load only when a pass-through-authorization or topology-leak finding is present, to ground the finding's OWASP API Security Top 10 classification and severity framing.
    
    ## Response minimum
    
    Return, at minimum:
    
    - the boundary decision (BFF aggregation vs. client-side composition) with justification tied to the number of backends, their auth models, and their reachability from the browser,
    - for any new/extended BFF route: an explicit scope statement and a check for an existing overlapping route,
    - a trust-boundary audit result (pass-through-authorization check, credential-forwarding check, topology-leak check) for any BFF route in scope,
    - ranked findings with file:line evidence, risk class, and fix,
    - the Next.js major version the caching claims were verified against, if a Route Handler is the proposed implementation,
    - verdict: approve / approve-with-notes / block,
    - evidence level and open questions.
    

Comments (0)

Sign in to join the conversation.

No comments yet.

Reviews (0)

No reviews yet.

Related