diff --git a/backend/server/dockerfile b/backend/server/dockerfile index 645f4d4..08b22ea 100644 --- a/backend/server/dockerfile +++ b/backend/server/dockerfile @@ -2,8 +2,8 @@ FROM node:20 # Security: Drop all capabilities USER root -RUN apt-get update && apt-get install -y libcap2-bin -RUN setcap cap_net_bind_service=+ep /usr/local/bin/node +RUN apt-get update && apt-get install -y libcap2-bin && \ + setcap cap_net_bind_service=+ep /usr/local/bin/node WORKDIR /code @@ -15,14 +15,19 @@ COPY . . RUN npm run build -# Security: Create non-root user and assign ownership -RUN useradd -m myuser -RUN mkdir projects && chown -R myuser:myuser projects -USER myuser +RUN useradd -m sboxuser +RUN mkdir projects && chown -R sboxuser:sboxuser projects -# user namespace mapping +# todo user namespace mapping -EXPOSE 3000 +RUN apt-get install -y firejail + +RUN echo '#!/bin/bash\nexec firejail --private=/projects --noprofile node dist/index.js' > /start.sh +RUN chmod +x /start.sh + +USER sboxuser + +EXPOSE 8000 EXPOSE 4000 -CMD [ "node", "dist/index.js" ] \ No newline at end of file +CMD ["/start.sh"] diff --git a/backend/server/src/index.ts b/backend/server/src/index.ts index c4195d3..b7ecd43 100644 --- a/backend/server/src/index.ts +++ b/backend/server/src/index.ts @@ -342,8 +342,8 @@ io.on("connection", async (socket) => { const onExit = pty.onExit((code) => console.log("exit :(", code)); + pty.write("export PS1='\\u > '\r"); pty.write("clear\r"); - pty.write("export PS1='> '\r"); terminals[id] = { terminal: pty, diff --git a/backend/storage/src/startercode.ts b/backend/storage/src/startercode.ts index a277023..495bbfb 100644 --- a/backend/storage/src/startercode.ts +++ b/backend/storage/src/startercode.ts @@ -56,7 +56,7 @@ import react from '@vitejs/plugin-react' export default defineConfig({ plugins: [react()], server: { - port: 3000, + port: 8000, }, }) `, diff --git a/frontend/components/editor/preview/index.tsx b/frontend/components/editor/preview/index.tsx index 34fbca7..7eb6f49 100644 --- a/frontend/components/editor/preview/index.tsx +++ b/frontend/components/editor/preview/index.tsx @@ -34,7 +34,7 @@ export default function PreviewWindow({