惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

F
Full Disclosure
WordPress大学
WordPress大学
小众软件
小众软件
Cloudbric
Cloudbric
AWS News Blog
AWS News Blog
腾讯CDC
量子位
人人都是产品经理
人人都是产品经理
大猫的无限游戏
大猫的无限游戏
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
V
Vulnerabilities – Threatpost
Scott Helme
Scott Helme
Hugging Face - Blog
Hugging Face - Blog
博客园_首页
C
CXSECURITY Database RSS Feed - CXSecurity.com
The Hacker News
The Hacker News
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
IT之家
IT之家
Jina AI
Jina AI
Attack and Defense Labs
Attack and Defense Labs
S
SegmentFault 最新的问题
Simon Willison's Weblog
Simon Willison's Weblog
The Cloudflare Blog
阮一峰的网络日志
阮一峰的网络日志
T
Tailwind CSS Blog
Last Week in AI
Last Week in AI
博客园 - 【当耐特】
Google Online Security Blog
Google Online Security Blog
美团技术团队
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
V
Visual Studio Blog
罗磊的独立博客
L
LINUX DO - 最新话题
博客园 - Franky
博客园 - 叶小钗
Apple Machine Learning Research
Apple Machine Learning Research
The Last Watchdog
The Last Watchdog
J
Java Code Geeks
AI
AI
C
Cisco Blogs
酷 壳 – CoolShell
酷 壳 – CoolShell
C
Cyber Attacks, Cyber Crime and Cyber Security
Cisco Talos Blog
Cisco Talos Blog
博客园 - 三生石上(FineUI控件)
雷峰网
雷峰网
Help Net Security
Help Net Security
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
云风的 BLOG
云风的 BLOG
I
Intezer
S
Securelist

NodeJS Security & NodeJS Secure Coding's Blog

Hardening Your npm and pnpm Configs in the Age of Shai-Hulud Argument Injection vulnerability in git-blame@1.4.0 Argument Injection vulnerability in `gits@0.1.8` Command Injection vulnerability in `@fab1o/git@1.4.0` Command Injection vulnerability in `git-contributors` via unsanitized CLI arguments Command Injection vulnerability in `git-q@0.0.3` Command injection vulnerability via unsanitized CLI arguments in touxing/fast-git-clone Command Injection vulnerability in `willitmerge@0.2.1` A Directory Traversal Vulnerability I found in Mastra AI Frameworks MCP Server Mastering NPX: A Cheatsheet for npm and Node.js Power Users The Tale of the Vulnerable MCP Database Server Bad Security Defaults in Mastra AI Frameworks Templates SQL Injection and Bypassing "Read-Only" Mode in Xata's MCP Server Security Advisory for qix npm supply-chain compromise affecting debug and billions of weekly download users How to Mitigate SQL Bypass in MCP Servers Enhancing MCP Server Security: A Guide to Using execFile Argument Injection Vulnerability in ggit How to Bypass Access Control in PostgreSQL in Simple PSQL MCP Server for SQL Injection Command Injection Flaws in ggit: Unveiling a Vulnerability Command Injection Vulnerability in Create MCP Server STDIO Tool Exposes System Monitoring Functions GitHub Kanban MCP Server Command Injection Vulnerability Threatens Developer Workflows Critical Command Injection Flaw in iOS Simulator MCP Server Exposes Development Environments Command Injection Vulnerability Discovered in Codehooks MCP Server: A Critical Security Analysis SSRF Shenanigans in safe-axios: Redirects Open the Backdoor SSRF Vulnerability in safe-axios: Unintended Public Address Classification Bypassing SSRF Safeguards in ssrfcheck: A Case of Incomplete Denylists Don't Be Fooled by Multicast, SSRF Bypass in private-ip Node.js Authentication from Lucia to Better Auth Bypassing SSRF Protection in nossrf: When Your Safeguards Become Loopholes Vue CLI Security Fix to Mitigate NPM Binary Planting Node.js API Security Vulnerabilities with Path Traversal in files-bucket-server Will You Accept These GPT 4o Secure Coding Recommendations? Command Injection Vulnerability in interactive-git-checkout npm package An Introduction to SSRF Bypasses and Denylist Failures Disclosing a Command Injection Vulnerability in `git-checkout-tool` Prisma Raw Query Leads to SQL Injection? Yes and No Flawed Git Promises Library on npm Leads to Command Injection Vulnerability Regex Gone Wrong: How parse-duration npm Package Can Crash Your Node.js App How I found an XSS in the Nuxt MDC Library for Markdown Content Holes in the Safety Net: Bypassing SSRF Protection in safe-axios How to Parse URLs from Markdown to HTML Securely? NPM Ignore Scripts Best Practices as Security Mitigation for Malicious Packages Where to find npm vulnerabilities? How to Hunt for IDOR Vulnerabilities To Exploit Security Misconfiguration? How to Avoid JWT Security Mistakes in Node.js Can a Node.js Secure Code Review Find Future Vulnerabilities? The Okta bcrypt Security Incident and The Bun vs Node.js Angle in Secure By Design NodeJS Path Traversal Vulnerability Scanner Do not use secrets in environment variables and here's how to do it better How to use npm audit How to use yarn audit Raw SQL Queries are Actually Better for Security Than ORMs? Node API Security Is Node.js Secure? URL Regex Validation: what can go wrong? Uncovering a Prototype Pollution Regression in the core Node.js project Deno CLI Vulnerability Repeats npm mistakes: CVE-2024-37150 Security skills for JavaScript developers Understanding and Preventing Prototype Pollution in Node.js How to protect against a security breach in React Server Components IDOR Vulnerability: What is it and how to prevent it? The security vulnerability of serving images via a route as opposed to static middleware in Node.js Why is it considered a bad practice to write raw SQL commands? JS Security Concepts for JavaScript Developers Secure Coding Practices in Node.js Against Path Traversal Vulnerabilities Secure JavaScript Coding Practices Against Command Injection Vulnerabilities To IDOR or Not to IDOR: Insecure Direct Object Reference in JavaScript Applications Explained npm vulnerabilities: reviewing the security of your dependencies Disclosing code injection vulnerabilities in safe-eval-2 npm package Introducing Node.js Security Permissions Model, Threat Model, and Security Releases Common Node.js Security Issues and How to Mitigate Them How JavaScript developers should embrace npm security The XZ backdoor CVE-2024-3094: a JavaScript perspective Node.js Security Best Practices The Case for Node.js Secure Configuration Protecting Against Common Node.js Vulnerabilities Input Validation Security Best Practices for Node.js A Node.js Vulnerability Scanner to Avoid Security Risks of EOL Runtime Versions JavaScript Security Issues in Node.js Applications OWASP Node.js Authentication, Authorization and Cryptography Practices OWASP Node.js Best Practices Guide Secure JavaScript Coding to Avoid Insecure Direct Object References (IDOR) North Korea malware on npm and Ledger connect-kit crypto heist 10 Best Practices for Secure Code Review of Node.js code Node.js and OWASP Top Ten Command Injection: Don't Let Your App Go 'BOOM' Secure Code Review Tips to Defend Against Vulnerable Node.js Code Destroyed by Dashes: How Two Hyphens Cause Argument Injection Vulnerability in blamer npm Package Securing Your Node.js Apps by Analyzing Real-World Command Injection Examples An Introduction to Command Injection Vulnerabilities in Node.js and JavaScript
Mitigate Supply Chain Security with DevContainers and 1Password for Node.js Local Development
2025-09-22 · via NodeJS Security & NodeJS Secure Coding's Blog

Do you want to mitigate and reduce the attack surface of supply chain security incidents on npm (and other language ecosystems)? I’ll show you how to setup an isolated Node.js local development environment with VS Code DevContainers and 1Password to keep secrets out of your filesystem.

Recent npm supply-chain attacks (e.g., qix maintainer compromise, and Shai-Hulud worm) showed how quickly malicious packages can steal developer tokens and secrets and then re-publish compromised packages at scale. Coverage from multiple security orgs notes hundreds of packages affected and emphasizes secret theft (npm, GitHub tokens, and cloud keys and API tokens) as a main objective. These campaigns follow earlier incidents like s1ngularity and the Qix compromise.

This guide shows how to:

  • Isolate your dev environment using VS Code devcontainers while maintaining a smooth developer experience.
  • Keep secrets out of dotenv files and out of your filesystem using 1Password CLI with a 1Password Connect server.

Host > Devcontainer > 1Password Connect > 1Password Cloud

What are Devcontainers?

Devcontainers are a Microsoft proposal that lets you open your project inside a container with the right tools and versions preinstalled on it. VS Code on your host machine (e.g: your macOS development environment) reads your devcontainer.json and handles build, create, start, and lifecycle hooks for you. The benefits are that you get reproducibility, consistent toolchains, fast onboarding and, of course, isolation.

Why Devcontainers Matter for Security

The devcontainer is a separate environment from your host. It has its own filesystem, network stack, and process tree. You can mount your project folder into the container and share ports back to your host, but otherwise, it’s isolated. Anything running inside the container can’t see your host’s files or processes unless you explicitly share them.

Essentially you get the following:

  • Isolation against credential exfiltration - Malicious postinstall scripts (or dev-time tooling) can’t trivially read your host’s ~/.npmrc, SSH keys, or random .env files if those never enter the container.
  • Sandboxing untrusted code - You can run packages from npm in a safer environment without giving them your host secrets by default.
  • Tighter control of secrets flow - With 1Password, secrets are injected just-in-time to processes that need them and not stored in repo.

Setting Up Devcontainers in VS Code

  1. Install the Dev Containers extension
  2. Add a .devcontainer/ folder to your project and start from the TypeScript & Node.js template
  3. VS Code will build and start your container per devcontainer.json. You can use lifecycle hooks like initializeCommand (host, pre-create), postCreateCommand (container, first create), and postStartCommand (container, every start)

The devcontainer.json file should look as follows:

// For format details, see https://aka.ms/devcontainer.json. For config options, see the

// README at: https://github.com/devcontainers/templates/tree/main/src/typescript-node

{

"name": "Node.js & TypeScript",

// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile

"image": "mcr.microsoft.com/devcontainers/typescript-node:1-22-bookworm",

"features": {

"ghcr.io/itsmechlark/features/1password:1.5.0": {}

},

"runArgs": [

"-e", "OP_CONNECT_HOST=http://host.docker.internal:8082",

"--env-file", "${localWorkspaceFolder}/.env.development"

],

// "postCreateCommand": "op --version",

// the initialize command should use the 1password cli "op read <vault-url-refercen" to populate the OP_CONNECT_HOST and OP_CONNECT_TOKEN as environment variables

"initializeCommand": "echo \"OP_CONNECT_TOKEN=\"$(op --account 123456 read 'op://LocalDev/1Password Token/password')\"\" >> ${localWorkspaceFolder}/.env.development"

// Features to add to the dev container. More info: https://containers.dev/features.

// "features": {},

// Use 'forwardPorts' to make a list of ports inside the container available locally.

// "forwardPorts": [8080]

// Use 'postCreateCommand' to run commands after the container is created.

// "postCreateCommand": "yarn install",

// Configure tool-specific properties.

// "customizations": {},

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.

// "remoteUser": "root"

}

We’ll touch on this configuration more later.

Introducing 1Password CLI (op)

I DO NOT RECOMMEND SECRETS IN DOTENV FILES and I’ve written comprehensively and extensively on this topic so I urge you: dDo not use secrets in environment variables and here’s how to do it better](https://www.nodejs-security.com/blog/do-not-use-secrets-in-environment-variables-and-here-is-how-to-do-it-better).

Hardcoding secrets in .env (or saving them long-term on disk) is risky so the 1Password CLI provides:

  • Secret references (op://vault/item/field) so code/configs never contain plaintext.
  • Three resolution modes at runtime:
    • op read prints a single secret
    • op run injects multiple secrets as env vars for a subprocess
    • op inject renders templates with secrets into files (useful as a host-side pre-start step) ([1Password Developer][6])

For containers and CI, 1Password recommends Connect (or service accounts) instead of relying on a desktop app socket. We’ll use 1Password Connect.

Set Up a 1Password Connect Server (on your host)

What is 1Password Connect? the 1Password Connect is a small API + sync pair you host. The CLI talks to Connect (with a token) to fetch secrets.

6.2 Prereqs you’ll obtain from 1Password

  • 1password-credentials.json (ties the server to your tenant)
  • A Connect token (scoped to specific vault(s)); rotate and scope with least privilege. You can create/limit tokens via op connect management commands.

There is a clear and easy guide to follow from the 1Password documentation here on setting up 1Password Connect.

Docker Compose (host)

To host the 1Password Connect server locally we’re going to use Docker Compose.

Create docker-compose.yml (host side):

version: "3.4"

services:

op-connect-api:

image: 1password/connect-api:latest

ports:

- "8082:8080"

volumes:

- "./1password-credentials.json:/home/opuser/.op/1password-credentials.json"

- "data:/home/opuser/.op/data"

op-connect-sync:

image: 1password/connect-sync:latest

ports:

- "8081:8080"

volumes:

- "./1password-credentials.json:/home/opuser/.op/1password-credentials.json"

- "data:/home/opuser/.op/data"

volumes:

data:

Note, you’ll notice I chose port 8082 which is different from their default of 8080 in the documentation. This is to avoid conflict with the devcontainer’s default Node.js port (8080) or with anything else you have running on your macOS host locally (e.g., another local server or some macOS service).

Anyways, now bring it up:

Verify:

# Health endpoint (no auth required)

curl -sS http://localhost:8082/health

# Example API call (needs the token)

curl -sS -H "Authorization: Bearer $OP_CONNECT_TOKEN" \

http://localhost:8082/v1/vaults | jq .

Tip: Keep 1Password Connect accessible only to trusted networks; the token is a bearer token (possession means access, however note that whoever gets the token needs access to your host-running Connect server to use it). Still, rotate on suspicion of any attack.

Add the 1Password CLI to your Devcontainer

Sadly, there’s no official devcontainer feature for 1Password yet, but you can add it easily via the official apt repo if you choose to build your own Dockerfile for devcontainer. Another option is to use a community-contributed devcontainer “feature” (you’ll find it on GitHub) and I referenced an example of it in the earlier devcontainer.json snippet above.

If you choose to use a Dockerfile then it should be as follows (Debian/Ubuntu base):

# Example base; you can also use mcr.microsoft.com/devcontainers/typescript-node

FROM debian:bookworm-slim

# Tools needed to add the official repo

RUN apt-get update && apt-get install -y curl gnupg ca-certificates apt-transport-https && \

rm -rf /var/lib/apt/lists/*

# Add 1Password official repo + key

RUN curl -sS https://downloads.1password.com/linux/keys/1password.asc \

| gpg --dearmor \

| tee /usr/share/keyrings/1password-archive-keyring.gpg >/dev/null && \

echo "deb [arch=amd64 signed-by=/usr/share/keyrings/1password-archive-keyring.gpg] https://downloads.1password.com/linux/debian/amd64 stable main" \

> /etc/apt/sources.list.d/1password.list

# Install the CLI

RUN apt-get update && apt-get install -y 1password-cli && \

rm -rf /var/lib/apt/lists/*

WORKDIR /workspace

This uses the official 1Password apt repo. After build, verify with op --version.

In this step, all we did was to make sure that we have the op CLI inside the devcontainer so that when we want to run npm run dev and access secrets there (without hardcoding them in .env files), we can access them via the 1Password vault. Next, we’ll wire it to Connect.

Wire the Devcontainer to Your Connect Server

Now, the thing is that the op CLI doesn’t have support for the native 1Password Desktop app integration via the socket inside containers. There are a few ways to get around it, one is to create a Service Token and another one is to use Connect. We’ll use Connect here as it is a more manageable approach for teams, you can scope tokens to specific vaults, and you can rotate them easily.

Choose the right Connect URL inside the container

If you’re a single dev in a team the you have 1Password Connect on your host (Docker Desktop on macOS/Windows), if that’s the case, use the magic DNS name host.docker.internal to reach your host from inside the container. So your Connect URL will be:

OP_CONNECT_HOST=http://host.docker.internal:8082

Remember, we exposed port 8082 on the host in the earlier Docker Compose step.

That hostname resolves to the host from within containers. Do not use http://localhost:8082 inside the container; localhost there is the container itself.

Note: Don’t forward ports for Connect in the devcontainer. Your devcontainer is a client, not serving Connect. forwardPorts is for exposing container ports out to the host and is unnecessary here. In some setups it can even interfere with outbound requests.

Securely provisioning OP_CONNECT_TOKEN without storing plaintext on host

Ok so how does the 1Password op CLI inside the container connects to Connect? It needs two environment variables:

  • OP_CONNECT_HOST (the URL of your Connect server)
  • OP_CONNECT_TOKEN (a bearer token to authenticate)

Well, you can set both as environment variables on the host and then just pass them into the container via devcontainer.json runArgs. However, that means you have the token in plaintext on your host which is not ideal. I don’t like it.

We’ll keep the token in 1Password and render it just before the container launches.

When the container starts, it will run an initializeCommand on the host (before the container is created) that will use the host’s op CLI (which can use the desktop app integration) to pull the token from 1Password and render it into a file. Then we’ll pass that file into the container as an env-file.

# Only the token lives here. Host is passed as localEnv (next step).

OP_CONNECT_TOKEN=""

Here is the full example of the script that does this rendering step:

devcontainer.json

{

"name": "node-secure-dev",

"build": { "dockerfile": "Dockerfile" },

// 1) On the HOST, before container create/build: pull token from 1Password

"initializeCommand": [ "bash", "-lc", ".devcontainer/fetch-secrets.sh" ],

// 2) Pass HOST value for OP_CONNECT_HOST; and pass the env-file with the token

"runArgs": [

"-e", "OP_CONNECT_HOST=${localEnv:OP_CONNECT_HOST}",

"--env-file", ".devcontainer/.env.container"

],

// 3) Quick sanity check inside the container

"postCreateCommand": "op --version"

}

How to set OP_CONNECT_HOST on the host (so ${localEnv:...} works):

# macOS shell (zsh/bash)

export OP_CONNECT_HOST="http://host.docker.internal:8082"

# Optionally add to ~/.zshrc if you launch VS Code from a terminal

Remove the Token File After Use

If you’re concerned about the token data OP_CONNECT_TOKEN being left on disk after the container is created, then you’re right to be. Let’s improve the workflow so that we remove the file once the container is created.

Add the following postStartCommand to your devcontainer.json:

{

// ... other config ...

"postStartCommand": "rm -f .devcontainer/.env.container"

}

Or a more robust config that checks if the file exists first:

// Once the container is created, the env is already set so we can remove the .env.development file that contains the token on-disk

"postStartCommand": "if [ -n \"./.env.development\" ]; then rm -f \"./.env.development\"; fi;"

This way, the token file is cleaned up after the container starts, reducing the risk of leaving sensitive information on disk.

Security Best Practices

  • Keep secrets out of Git: .env.container, .env.development, and anything rendered with op inject should be in .gitignore.
  • Lock down file perms: chmod 600 for any rendered env file.
  • Rotate tokens: Treat OP_CONNECT_TOKEN like a password. Revoke/replace if exposed.
  • Network boundaries: Prefer Connect reachable only from your dev machine (and CI), not the public internet.
  • Understand the threat: Recent npm attacks steal secrets and propagate; the goal is persistent access. JIT secrets and isolation reduce blast radius.

Conclusion & Next Steps

So here’s what we’ve accomplished:

  • Isolating our dev environment, reduced secret exposure, and aligned with best practices learned from recent npm incidents.
  • Using op run to inject secrets just-in-time, avoiding plaintext storage on disk or in repo.
  • Limiting third-party software install scope to the container, reducing host risk from any sort of malware related to supply-chain attacks.

Good luck avoiding the next supply chain incident :-)