Execution with Unnecessary Privileges
The product performs an operation at a privilege level that is higher than the minimum level required, which creates new weaknesses or amplifies the consequences of other weaknesses.
New weaknesses can be exposed because running with extra privileges gives the product access to resources that are not necessary. In addition, if an attacker can trigger the operation with the higher privileges, the attacker might gain root or administrator privileges.
इस भेद्यता को कैसे ठीक करें
Add a USER instruction before CMD/ENTRYPOINT to run as non-root
FROM node:24-alpine WORKDIR /app COPY . . RUN npm ci + RUN addgroup -S appuser && adduser -S appuser -G appuser + USER appuser CMD ["node", "server.js"]
Use a non-root user and restrictive file permissions instead of USER root or chmod 777
FROM node:24-alpine - USER root - RUN chmod 777 /app - COPY . /app + RUN addgroup -S appuser && adduser -S appuser -G appuser + WORKDIR /app + COPY --chown=appuser:appuser . . + RUN chmod 755 /app + USER appuser CMD ["node", "server.js"]
Set allowPrivilegeEscalation: false to prevent containers from gaining additional privileges
apiVersion: v1 kind: Pod spec: containers: - name: app image: nginx:1.25 securityContext: - allowPrivilegeEscalation: true + allowPrivilegeEscalation: false
Remove dangerous capabilities like SYS_ADMIN, NET_ADMIN, SYS_PTRACE and drop ALL instead
apiVersion: v1 kind: Pod spec: containers: - name: app image: nginx:1.25 securityContext: capabilities: - add: - - SYS_ADMIN - - NET_ADMIN + drop: + - ALL + add: + - NET_BIND_SERVICE
Disable host namespace access (hostNetwork, hostPID, hostIPC) to isolate pods from the host
apiVersion: v1 kind: Pod spec: - hostNetwork: true - hostPID: true + hostNetwork: false + hostPID: false + hostIPC: false containers: - name: app image: nginx:1.25
अपने कोड में भेद्यताएँ खोजें
Execution with Unnecessary Privileges पैटर्न के लिए अपने कोडबेस को स्कैन करने के लिए Shoulder का उपयोग करें। 10 नियम.
# Scan with Shoulder CLI npx @shoulderdev/cli trust --cwe=250 # Or scan entire project npx @shoulderdev/cli trust .
पहचान नियम (10)
कोड समीक्षा में किन बातों पर ध्यान दें
ये पैटर्न संभावित Execution with Unnecessary Privileges भेद्यताओं का संकेत देते हैं। कोड समीक्षा और सुरक्षा ऑडिट के दौरान इन्हें देखें।
अपने कोडबेस को इसके लिए स्कैन करें: Execution with Unnecessary Privileges
Shoulder CLI आपके पूरे कोडबेस में भेद्य पैटर्न खोजता है।