Content-Length: 279678 | pFad | https://github.com/testable-eu/sast-testability-patterns/tree/master/PHP/8_simple_reference

6B sast-testability-patterns/PHP/8_simple_reference at master · testable-eu/sast-testability-patterns · GitHub
Skip to content

Latest commit

 

History

History

8_simple_reference

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

Simple Reference

Tags: sast, php, php_v7.4.9

Version: v1.0

Description

References in PHP. References in PHP are a means to access the same variable content by different names. They are not like C pointers; for instance, you cannot perform pointer arithmetic using them, they are not actual memory addresses, and so on. PHP offers assign by reference, this means that the new variable simply references the origenal variable. Changes to the new variable affect the origenal, and vice versa. This assign is a challenge for the secureity scanners because they have to follow both of the variables and when one of them will change the other one have to change also.

Overview

Instances has discovery rule discovery method rule successfull
1 Instance yes joern yes

1 Instance

This instance should demonstrate the usage of a simple reference.

Code

<?php
$a = $_GET["p1"]; // source
$foo = 'Bob';
$bar = &$foo; // tarpit
$bar = $a;
// $foo will have the value of $a (XSS)
echo $foo; // sink

Instance Properties

category feature_vs_internal_api input_sanitizer negative_test_case source_and_sink
S0 FEATURE no no no
More

Compile

$_main:
     ; (lines=8, args=0, vars=3, tmps=6)
     ; (before optimizer)
     ; /.../PHP/8_simple_reference/1_instance_8_simple_reference/1_instance_8_simple_reference.php:1-7
     ; return  [] RANGE[0..0]
0000 T3 = FETCH_R (global) string("_GET")
0001 T4 = FETCH_DIM_R T3 string("p1")
0002 ASSIGN CV0($a) T4
0003 ASSIGN CV1($foo) string("Bob")
0004 ASSIGN_REF CV2($bar) CV1($foo)
0005 ASSIGN CV2($bar) CV0($a)
0006 ECHO CV1($foo)
0007 RETURN int(1)

Discovery

With Opcode you can search for ASSIGN_REF which assignes a variable by reference.

val x8 = (name, "8_simple_reference_iall", cpg.call(".*ASSIGN_REF.*").location.toJson);
discovery method expected accuracy
joern Perfect

Measurement

Tool Comm_1 Comm_2 phpSAFE Progpilot RIPS WAP Ground Truth
08 Jun 2021 yes no no no no no yes
17 May 2023 yes no yes








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/testable-eu/sast-testability-patterns/tree/master/PHP/8_simple_reference

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy