बीटा Shoulder बीटा में है — परिणाम कभी-कभी गलत हो सकते हैं। आपकी प्रतिक्रिया तय करती है कि हम आगे क्या ठीक करें। प्रतिक्रिया साझा करें
🔒

Exposure of Resource to Wrong Sphere

🛡️ 3 नियम इसे पहचानते हैं

Exposure of Resource to Wrong Sphere

The product exposes a resource to the wrong control sphere, providing unintended actors with inappropriate access to the resource.

Resources should only be accessible to actors that are intended to use them. When resources are exposed to the wrong sphere (e.g., public instead of private), unauthorized actors can access sensitive data or functionality.

व्यापकता
उच्च
बार-बार शोषित
प्रभाव
क्रिटिकल
1 क्रिटिकल गंभीरता वाले नियम
रोकथाम
प्रलेखित
3 फिक्स उदाहरण
2 रोकथाम
2 रोकथाम

इस भेद्यता को कैसे ठीक करें

HostPath Volume Mounted CRITICAL

Use PersistentVolumeClaim or emptyDir instead of hostPath volumes

+2 -2 yaml
  apiVersion: v1
  kind: Pod
  spec:
    volumes:
    - name: data
-     hostPath:
-       path: /data
+     persistentVolumeClaim:
+       claimName: app-data-pvc
    containers:
    - name: app
      image: nginx:1.25
      volumeMounts:
      - name: data
        mountPath: /app/data
  
NodePort Service Exposes Application MEDIUM

Use ClusterIP with Ingress or LoadBalancer instead of NodePort for production services

+4 -4 yaml
  apiVersion: v1
  kind: Service
  spec:
-   type: NodePort
-   ports:
-     - port: 80
-       nodePort: 30080
+   type: ClusterIP
+   ports:
+     - port: 80
+       targetPort: 8080
  
TypeScript Access Modifier Bypass HIGH

Use ECMAScript private fields (#) for true runtime encapsulation instead of TypeScript's compile-time-only modifiers

+16 -12 javascript
  class UserSession {
-   private token: string;
-   private _refreshToken: string;
- 
-   constructor(token: string, refresh: string) {
-     this.token = token;
-     this._refreshToken = refresh;
-   }
- }
- 
- const session = new UserSession('abc', 'xyz');
- const leaked = (session as any).token;
- const alsoLeaked = session['_refreshToken'];
+   #token: string;
+   #refreshToken: string;
+ 
+   constructor(token: string, refresh: string) {
+     this.#token = token;
+     this.#refreshToken = refresh;
+   }
+ 
+   validateToken(input: string): boolean {
+     return this.#token === input;
+   }
+ }
+ 
+ const session = new UserSession('abc', 'xyz');
+ // session.#token -> SyntaxError at runtime
+ // session['#token'] -> undefined
  
3 पहचान
3 पहचान

अपने कोड में भेद्यताएँ खोजें

Exposure of Resource to Wrong Sphere पैटर्न के लिए अपने कोडबेस को स्कैन करने के लिए Shoulder का उपयोग करें। 3 नियम.

टर्मिनल
# Scan with Shoulder CLI
npx @shoulderdev/cli trust --cwe=668

# Or scan entire project
npx @shoulderdev/cli trust .
4 चेतावनी संकेत
4 चेतावनी संकेत

कोड समीक्षा में किन बातों पर ध्यान दें

ये पैटर्न संभावित Exposure of Resource to Wrong Sphere भेद्यताओं का संकेत देते हैं। कोड समीक्षा और सुरक्षा ऑडिट के दौरान इन्हें देखें।

🟠
Access modifier bypass detected using .... Private/protected fields accessed through runtime mechanisms. typescript-access-modifier-bypass
🟡
Service uses NodePort type which exposes the application on all cluster nodes. kubernetes-nodeport-service
🟡
services using NodePort type which exposes the application on all cluster nodes kubernetes-nodeport-service
🔴
HostPath volumes mount directories from the host filesystem into the pod. kubernetes-hostpath-volume
🔴
HostPath volumes that mount directories from the host filesystem into pods kubernetes-hostpath-volume
🔍

अपने कोडबेस को इसके लिए स्कैन करें: Exposure of Resource to Wrong Sphere

Shoulder CLI आपके पूरे कोडबेस में भेद्य पैटर्न खोजता है।