Skip to content

Commit f15e31b

Browse files
Fix npx removal to also delete the target script
The symlink at /root/.nvm/.../bin/npx points to npx-cli.js. Remove both to ensure npx is fully disabled. Co-authored-by: Ona <no-reply@ona.com>
1 parent abac094 commit f15e31b

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

.devcontainer/Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,10 @@ RUN npm config set ignore-scripts true --location=global && \
343343
echo 'ignore-scripts true' >> ~/.yarnrc
344344

345345
# Disable npx (security hardening - prevents arbitrary package execution)
346-
RUN rm -f /usr/bin/npx /usr/local/bin/npx /root/.nvm/versions/node/v${NODE_VERSION}/bin/npx && \
346+
# Remove npx from NVM and replace with stub that prints warning
347+
RUN rm -f /usr/bin/npx /usr/local/bin/npx && \
348+
rm -f /root/.nvm/versions/node/v${NODE_VERSION}/bin/npx && \
349+
rm -f /root/.nvm/versions/node/v${NODE_VERSION}/lib/node_modules/npm/bin/npx-cli.js && \
347350
echo '#!/bin/sh' > /usr/local/bin/npx && \
348351
echo 'echo "npx is disabled for security reasons. Use explicit package installation instead." >&2' >> /usr/local/bin/npx && \
349352
echo 'exit 1' >> /usr/local/bin/npx && \

0 commit comments

Comments
 (0)