Passed
Push — master ( 034956...2b8b29 )
by Maja
16:38
created

cat_socket()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 7
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 9
rs 10
1
<?php
2
define('SOCKET', '/opt/Socket/CAT_requests/queue');
3
define('OPNAME_PREFIX', '1hostspot-');
4
define('OPNAME_SUFFIX', '.hosted.eduroam.org');
5
6
function cat_socket($obj) {
7
   $sock = socket_create(AF_UNIX, SOCK_STREAM, 0);
8
   $conn = socket_connect($sock, SOCKET);
9
   if ( $conn ) {
10
     socket_write ($sock, $obj, strlen($obj));
0 ignored issues
show
Security Header Injection introduced by
$obj can contain request data and is used in request header context(s) leading to a potential security vulnerability.

7 paths for user data to reach this point

  1. Path: Read from $_REQUEST in ansible/ManagedSP/templates/web/index.php on line 26
  1. Read from $_REQUEST
    in ansible/ManagedSP/templates/web/index.php on line 26
  2. Data is passed through implode(), and cat_socket() is called
    in ansible/ManagedSP/templates/web/index.php on line 25
  3. Enters via parameter $obj
    in ansible/ManagedSP/templates/web/lib.inc on line 6
  2. Path: Read from $_REQUEST, and Data is passed through implode(), and cat_socket() is called in ansible/ManagedSP/templates/web/index.php on line 25
  1. Read from $_REQUEST, and Data is passed through implode(), and cat_socket() is called
    in ansible/ManagedSP/templates/web/index.php on line 25
  2. Enters via parameter $obj
    in ansible/ManagedSP/templates/web/lib.inc on line 6
  3. Path: Read from $_REQUEST in ansible/ManagedSP/templates/web/index.php on line 27
  1. Read from $_REQUEST
    in ansible/ManagedSP/templates/web/index.php on line 27
  2. Data is passed through implode(), and cat_socket() is called
    in ansible/ManagedSP/templates/web/index.php on line 25
  3. Enters via parameter $obj
    in ansible/ManagedSP/templates/web/lib.inc on line 6
  4. Path: Read from $_REQUEST, and Data is passed through trim(), and trim($_REQUEST['operatorname']) is assigned to $opn in ansible/ManagedSP/templates/web/index.php on line 15
  1. Read from $_REQUEST, and Data is passed through trim(), and trim($_REQUEST['operatorname']) is assigned to $opn
    in ansible/ManagedSP/templates/web/index.php on line 15
  2. Data is passed through base64_encode()
    in ansible/ManagedSP/templates/web/index.php on line 29
  3. Data is passed through implode(), and cat_socket() is called
    in ansible/ManagedSP/templates/web/index.php on line 25
  4. Enters via parameter $obj
    in ansible/ManagedSP/templates/web/lib.inc on line 6
  5. Path: Read from $_REQUEST, and Data is passed through base64_encode() in ansible/ManagedSP/templates/web/index.php on line 28
  1. Read from $_REQUEST, and Data is passed through base64_encode()
    in ansible/ManagedSP/templates/web/index.php on line 28
  2. Data is passed through implode(), and cat_socket() is called
    in ansible/ManagedSP/templates/web/index.php on line 25
  3. Enters via parameter $obj
    in ansible/ManagedSP/templates/web/lib.inc on line 6
  6. Path: Read from $_REQUEST, and Data is passed through trim(), and OPNAME_PREFIX . trim($_REQUEST['instid']) . '-' . trim($_REQUEST['deploymentid']) . OPNAME_SUFFIX is assigned to $opn in ansible/ManagedSP/templates/web/index.php on line 17
  1. Read from $_REQUEST, and Data is passed through trim(), and OPNAME_PREFIX . trim($_REQUEST['instid']) . '-' . trim($_REQUEST['deploymentid']) . OPNAME_SUFFIX is assigned to $opn
    in ansible/ManagedSP/templates/web/index.php on line 17
  2. Data is passed through base64_encode()
    in ansible/ManagedSP/templates/web/index.php on line 29
  3. Data is passed through implode(), and cat_socket() is called
    in ansible/ManagedSP/templates/web/index.php on line 25
  4. Enters via parameter $obj
    in ansible/ManagedSP/templates/web/lib.inc on line 6
  7. Path: Read from $_REQUEST, and $_REQUEST['vlan'] . '#' . implode('#', $_REQUEST['realmforvlan']) is assigned to $vlans in ansible/ManagedSP/templates/web/index.php on line 21
  1. Read from $_REQUEST, and $_REQUEST['vlan'] . '#' . implode('#', $_REQUEST['realmforvlan']) is assigned to $vlans
    in ansible/ManagedSP/templates/web/index.php on line 21
  2. Data is passed through base64_encode()
    in ansible/ManagedSP/templates/web/index.php on line 30
  3. Data is passed through implode(), and cat_socket() is called
    in ansible/ManagedSP/templates/web/index.php on line 25
  4. Enters via parameter $obj
    in ansible/ManagedSP/templates/web/lib.inc on line 6

General Strategies to prevent injection

In general, it is advisable to prevent any user-data to reach this point. This can be done by white-listing certain values:

if ( ! in_array($value, array('this-is-allowed', 'and-this-too'), true)) {
    throw new \InvalidArgumentException('This input is not allowed.');
}

For numeric data, we recommend to explicitly cast the data:

$sanitized = (integer) $tainted;
Loading history...
11
     $out = socket_read ($sock, 2048);
12
     return $out;
13
   }
14
   return 'FAILURE';
15
}
16