
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
[](https://github.com/kubewarden/community/blob/main/REPOSITORIES.md#sandbox) [](https://o
[!WARNING] The SDK is experimental and under active development.
The official JavaScript/TypeScript SDK for writing Kubewarden policies. This SDK allows you to write Kubernetes admission policies using TypeScript/JavaScript that compile to WebAssembly modules.
npm install kubewarden-policy-sdk
import { Validation, writeOutput } from 'kubewarden-policy-sdk';
function validate() {
// Read the admission request
const validationRequest = Validation.readValidationRequest();
const settings = validationRequest.settings;
// Your policy logic here
const isValid = yourValidationLogic(validationRequest.request);
// Create response
const response = new Validation.ValidationResponse(
isValid,
isValid ? undefined : 'Request rejected by policy',
undefined, // mutated_object (for mutating policies)
undefined, // warnings
{ customData: 'example' }, // annotations
);
// Write the response
writeOutput(response);
}
// Export the validate function
(globalThis as any).validate = validate;
[!IMPORTANT]
Logging tostdoutwill break your policy. Always useconsole.error()for logging instead ofconsole.log()to avoid policy failures.
The SDK provides access to Kubewarden's host capabilities:
import { hostCapabilities } from 'kubewarden-policy-sdk';
// DNS lookup
const dnsResult = hostCapabilities.Net.lookupHost('example.com');
console.error('IPs:', dnsResult.ips);
import { hostCapabilities } from 'kubewarden-policy-sdk';
// Get OCI manifest
const manifest = hostCapabilities.OciManifest.getManifest('registry.io/image:tag');
console.error('Manifest:', manifest);
// Verify image signatures
const verificationResult = hostCapabilities.OciSignatureVerifier.verifyPubKeysImage(
'registry.io/image:tag',
['-----BEGIN PUBLIC KEY-----\n...\n-----END PUBLIC KEY-----'],
);
import { hostCapabilities } from 'kubewarden-policy-sdk';
// Get a Kubernetes resource
const resource = hostCapabilities.Kubernetes.getResource({
apiVersion: 'v1',
kind: 'Pod',
name: 'my-pod',
namespace: 'default',
});
// List resources
const pods = hostCapabilities.Kubernetes.listResourcesByNamespace({
apiVersion: 'v1',
kind: 'Pod',
namespace: 'default',
});
import { hostCapabilities } from 'kubewarden-policy-sdk';
// Verify certificate
const cert = hostCapabilities.Crypto.CertificateUtils.fromString(
'-----BEGIN CERTIFICATE-----\n...\n-----END CERTIFICATE-----',
'Pem',
);
const verificationResult = hostCapabilities.Crypto.verifyCert(
cert,
[], // certificate chain
'2025-12-31T23:59:59Z', // not_after
);
import { Validation, writeOutput } from 'kubewarden-policy-sdk';
import type { Pod } from 'kubernetes-types/core/v1';
interface PolicySettings {
ignoredNamespaces?: string[];
allowPrivileged?: boolean;
}
function validate() {
const validationRequest = Validation.readValidationRequest();
const settings = validationRequest.settings as PolicySettings;
const pod = validationRequest.request.object as Pod;
// Skip validation for ignored namespaces
if (settings.ignoredNamespaces?.includes(pod.metadata?.namespace || '')) {
writeOutput(new Validation.ValidationResponse(true));
return;
}
// Check for privileged containers
const hasPrivilegedContainers =
pod.spec?.containers?.some(container => container.securityContext?.privileged === true) ||
false;
if (hasPrivilegedContainers && !settings.allowPrivileged) {
writeOutput(
new Validation.ValidationResponse(
false,
'Privileged containers are not allowed',
undefined,
undefined,
{ violationType: 'privileged-container' },
),
);
return;
}
writeOutput(new Validation.ValidationResponse(true));
}
(globalThis as any).validate = validate;
Validation.ValidationResponsenew ValidationResponse(
accepted: boolean, // Whether the request is accepted
message?: string, // Optional rejection message
mutated_object?: any, // For mutating admission controllers
warnings?: string[], // Optional warnings
annotations?: Record<string, string> // Custom annotations
)
Validation.readValidationRequest()Reads and parses the incoming Kubernetes admission request.
lookupHost(hostname: string): DNS resolutiongetManifest(image: string): Get OCI manifestgetManifestConfig(image: string): Get manifest configurationgetManifestDigest(image: string): Get manifest digestverifyPubKeysImage(image: string, pubKeys: string[]): Verify with public keysverifyKeylessExactMatch(image: string, keyless: KeylessInfo[]): Keyless verificationverifyKeylessPrefix(image: string, keyless: KeylessPrefixInfo[]): Prefix-based keyless verificationverifyGithubActions(image: string, owner: string): GitHub Actions verificationgetResource(request: GetResourceRequest): Get a specific resourcelistResourcesByNamespace(request: ListResourcesRequest): List resources in namespacelistAllResources(request: ListResourcesRequest): List all resourcescanI(request: CanIRequest): Check permissions using the Kubernetes authorization APIverifyCert(cert: Certificate, certChain: Certificate[], notAfter?: string): Verify certificatesCertificateUtils.fromString(certString: string, encoding: CertificateEncoding): Create certificate from stringCertificateUtils.toString(cert: Certificate): Convert certificate to stringFor complete documentation of all available host capabilities, see the Kubewarden Host Capabilities Reference.
Install the SDK:
npm install kubewarden-policy-sdk
Write your policy (e.g., main.ts)
Set up your project structure with appropriate package.json, tsconfig.json, and webpack.config.js
Build the policy:
make build # Compile TypeScript and bundle JavaScript
make annotated-policy.wasm # Compile to WebAssembly and annotate
Test your policy:
kwctl run annotated-policy.wasm -r request.json
The Javy plugin required for compilation is included in the package at:
node_modules/kubewarden-policy-sdk/plugin/javy-plugin-kubewarden.wasm
The SDK includes comprehensive testing utilities. See the demo policy for examples of:
The best way to get started is with the JavaScript Policy Template which provides a ready-to-use project structure and examples.
You can also check out the demo policy in this repository for a complete working example that demonstrates:
We welcome contributions! Please see the contributing guidelines for more information.
git clone https://github.com/kubewarden/policy-sdk-js.git
cd policy-sdk-js/js
npm install
npm test
This project is licensed under the Apache 2.0 License - see the LICENSE file for details.
FAQs
[](https://github.com/kubewarden/community/blob/main/REPOSITORIES.md#sandbox) [](https://o
We found that test-kw demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.