Proteggere i remote di Module Federation
Impari a proteggere il meccanismo stesso di caricamento dei remote, impedendo agli aggressori di iniettare o manomettere il codice federato durante l’esecuzione.
Proteggere i remote di Module Federation è una lezione Micro Frontends Architecture with Module Federation gratuita su CoddyKit. Questa è la lezione 4 di 4. Puoi leggere la lezione completa qui gratuitamente — poi esercitati direttamente nel browser con un editor di codice integrato e un tutor IA disponibile 24/7. Fa parte del percorso di apprendimento Micro Frontends Architecture with Module Federation, e i tuoi progressi si sincronizzano tra il web e l'app CoddyKit. Il corso Micro Frontends Architecture with Module Federation include 4 lezioni in totale.
Parti di questa lezione non sono ancora state tradotte e vengono mostrate in inglese.
Remotes Are Live Code
Module Federation fetches and executes remote JavaScript at run time. That power is also a risk: if an attacker controls a remote URL, they can run code inside your app.
The Threat: Remote Tampering
Key threats to the federation layer include:
- A compromised remote host serving malicious code
- Man-in-the-middle modification of
remoteEntry.js - Loading a remote from an unexpected origin
Always Serve Over HTTPS
Loading any remote over plain HTTP allows in-transit tampering. Every remoteEntry.js and chunk must be served over HTTPS, with HSTS enforced.
Allowlist Remote Origins
Do not load remotes from arbitrary URLs. Restrict allowed origins with a Content Security Policy so only trusted hosts can supply scripts.
Content-Security-Policy: script-src 'self' https://cdn.trusted.comSubresource Integrity (SRI)
SRI lets the browser verify a fetched script matches a known hash, rejecting it if it was altered. Pairing SRI with federation guards against tampered remotes.
<script src="/cart/remoteEntry.js"
integrity="sha384-..." crossorigin="anonymous">Validate the Remote Manifest
If you load remote URLs from a manifest, that manifest is a high-value target. Serve it from a trusted origin and validate its contents before using any URL.
Avoid Dynamic Untrusted URLs
Never build a remote URL from user input or untrusted config. An attacker who influences the URL can point your app at malicious code.
// dangerous:
import(userProvidedUrl);
// safe: import from a fixed allowlisted nameIsolate Remotes Where Possible
Because remotes share the same page context, a malicious remote can read the DOM and globals. For untrusted third-party MFEs, consider iframe or sandbox isolation.
Protect Shared State and Tokens
A compromised remote can read shared stores and globals. Never place raw auth tokens on window or in shared state where any remote could harvest them.
Verify Integrity in CI/CD
Generate and pin SRI hashes during the build, and check that deployed remoteEntry files match expected hashes, so a tampered artifact fails verification before users hit it.
Defense in Depth
No single control is enough. Combine HTTPS, CSP allowlists, SRI, manifest validation, and isolation so that bypassing one layer still leaves others protecting the app.
Quick Check
Test your federation-security knowledge.
Recap
You learned to secure federation remotes:
- Remotes execute live code, so the loader is an attack surface
- Always use HTTPS and a CSP script-src allowlist
- Verify integrity with SRI and hash checks in CI
- Never load remotes from untrusted URLs
- Isolate untrusted MFEs and protect tokens
Defense in depth keeps federated code trustworthy.
Impara JavaScript con un tutor IA — gratis
Scrivi ed esegui vero codice nel tuo browser, ricevi aiuto istantaneo da un tutor IA disponibile 24/7, e riprendi da dove hai lasciato sul web o nell'app.
- Corsi
- 12
- Lezioni
- 48
Domande Frequenti
La lezione «Proteggere i remote di Module Federation» è gratuita?
Sì — il testo completo di «Proteggere i remote di Module Federation» è gratuito qui sul web. Per esercitarvi in modo interattivo (un editor di codice integrato e un tutor IA 24/7) e sbloccare il resto del corso Micro Frontends Architecture with Module Federation, passa a CoddyKit PRO. Il corso Micro Frontends Architecture with Module Federation include 4 lezioni in totale.
Cosa imparerò in «Proteggere i remote di Module Federation»?
Impari a proteggere il meccanismo stesso di caricamento dei remote, impedendo agli aggressori di iniettare o manomettere il codice federato durante l’esecuzione. Eserciti Micro Frontends Architecture with Module Federation con codice pratico che esegui direttamente nel browser, e un tutor IA 24/7 risponde alle tue domande mentre lavori sulla lezione.
Ho bisogno di esperienza per iniziare Micro Frontends Architecture with Module Federation?
Non è richiesta alcuna esperienza precedente. Micro Frontends Architecture with Module Federation su CoddyKit è strutturato per principianti e studenti avanzati, quindi puoi iniziare da qui o dall'inizio e procedere al tuo ritmo. Questa è la lezione 4 di 4.
Quanto tempo richiede la lezione «Proteggere i remote di Module Federation»?
La maggior parte delle lezioni CoddyKit richiede circa 5–10 minuti. Ogni lezione è breve e interattiva, quindi fai progressi costanti e riprendi esattamente da dove hai lasciato su web e app.
Posso scrivere ed eseguire codice in questa lezione Micro Frontends Architecture with Module Federation?
Sì. Ogni lezione Micro Frontends Architecture with Module Federation include un editor di codice integrato, quindi scrivi ed esegui codice reale direttamente nel tuo browser e ricevi feedback istantaneo dall'IA — nessuna configurazione locale necessaria.
Tutte le lezioni di questo corso
- Autenticazione e autorizzazione
- Rischi di sicurezza tra applicazioni
- Best practice per una federazione sicura
- Proteggere i remote di Module Federation