Details

    • Type: Language-Specification
    • Status: Active
    • Resolution: Unresolved
    • Labels:
    • Impact:
      Unknown 'null' severity
    • Likelihood:
      Unknown 'null' severity
    • Default Quality Profiles:
      Sonar way, Sonar way recommended

      Description

      Sensitive Code Example

      nodejs http built-in module:

      const http = require('http');
      const srv = http.createServer((req, res) => {
        res.writeHead(200, { 'Access-Control-Allow-Origin': '*' }); // Sensitive
        res.end('ok');
      });
      srv.listen(3000);
      

      Express.js framework with cors middleware:

      const cors = require('cors');
      
      let app1 = express();
      app1.use(cors()); // Sensitive: by default origin is set to *
      
      let corsOptions = {
        origin: '*' // Sensitive
      };
      
      let app2 = express();
      app2.use(cors(corsOptions));
      

      Compliant Solution

      nodejs http built-in module:

      const http = require('http');
      const srv = http.createServer((req, res) => {
        res.writeHead(200, { 'Access-Control-Allow-Origin': 'trustedwebsite.com' }); // Compliant
        res.end('ok');
      });
      srv.listen(3000);
      

      Express.js framework with cors middleware:

      const cors = require('cors');
      
      let corsOptions = {
        origin: 'trustedwebsite.com' // Compliant
      };
      
      let app = express();
      app.use(cors(corsOptions));
      

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              lars.svensson Lars Svensson (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: