Skip to content

Commit e168a9c

Browse files
author
Cornelius Ludmann
committed
[dev] disable npm lifecycle scripts and npx
1 parent f650690 commit e168a9c

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

.devcontainer/Dockerfile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,18 @@ RUN curl -fsSL https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh |
337337
&& nvm alias default v${NODE_VERSION} \
338338
&& npm install -g typescript yarn pnpm node-gyp @anthropic-ai/claude-code"
339339

340+
# Disable npm/yarn lifecycle scripts by default (security hardening)
341+
# To allow specific packages, use: npm rebuild <package> or yarn rebuild <package>
342+
RUN npm config set ignore-scripts true --location=user && \
343+
echo 'ignore-scripts true' >> ~/.yarnrc
344+
345+
# Disable npx (security hardening - prevents arbitrary package execution)
346+
RUN rm -f /usr/bin/npx /usr/local/bin/npx && \
347+
echo '#!/bin/sh' > /usr/local/bin/npx && \
348+
echo 'echo "npx is disabled for security reasons. Use explicit package installation instead." >&2' >> /usr/local/bin/npx && \
349+
echo 'exit 1' >> /usr/local/bin/npx && \
350+
chmod +x /usr/local/bin/npx
351+
340352
ENV PATH=$PATH:/root/.aws-iam:/root/.terraform:/workspace/bin
341353

342354
### Telepresence ###

0 commit comments

Comments
 (0)