mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-14 04:02:26 +00:00
fix(security): support SRI integrity verification for dashboard plugin scripts
This commit is contained in:
parent
46d1fc16ab
commit
5909526a06
2 changed files with 16 additions and 0 deletions
|
|
@ -22,6 +22,12 @@ export interface PluginManifest {
|
||||||
entry: string;
|
entry: string;
|
||||||
css?: string | null;
|
css?: string | null;
|
||||||
has_api: boolean;
|
has_api: boolean;
|
||||||
|
/**
|
||||||
|
* Optional Subresource Integrity hash (e.g. "sha384-..."). When set,
|
||||||
|
* the browser will refuse to execute the plugin bundle if its hash
|
||||||
|
* does not match. This protects against tampered plugin delivery.
|
||||||
|
*/
|
||||||
|
integrity?: string;
|
||||||
source: string;
|
source: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -68,6 +68,16 @@ export function usePlugins() {
|
||||||
script.setAttribute("data-hermes-plugin", manifest.name);
|
script.setAttribute("data-hermes-plugin", manifest.name);
|
||||||
script.src = scriptSrc;
|
script.src = scriptSrc;
|
||||||
script.async = true;
|
script.async = true;
|
||||||
|
// SRI integrity verification — defense against compromised plugin
|
||||||
|
// delivery. Plugin manifests can declare an integrity hash
|
||||||
|
// (e.g. "sha384-...") which the browser verifies before executing.
|
||||||
|
// Without this, a man-in-the-middle or compromised plugin server
|
||||||
|
// can substitute the JS bundle silently. Opt-in: when no integrity
|
||||||
|
// is declared in the manifest, behavior is unchanged.
|
||||||
|
if (manifest.integrity && typeof manifest.integrity === "string") {
|
||||||
|
script.integrity = manifest.integrity;
|
||||||
|
script.crossOrigin = "anonymous";
|
||||||
|
}
|
||||||
script.onerror = () => {
|
script.onerror = () => {
|
||||||
setPluginLoadError(manifest.name, "LOAD_FAILED");
|
setPluginLoadError(manifest.name, "LOAD_FAILED");
|
||||||
console.warn(
|
console.warn(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue