BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//pretalx//cfp.pass-the-salt.org//pts2023//speaker//NCLGMX
BEGIN:VTIMEZONE
TZID:CET
BEGIN:STANDARD
DTSTART:20001029T040000
RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10
TZNAME:CET
TZOFFSETFROM:+0200
TZOFFSETTO:+0100
END:STANDARD
BEGIN:DAYLIGHT
DTSTART:20000326T030000
RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=3
TZNAME:CEST
TZOFFSETFROM:+0100
TZOFFSETTO:+0200
END:DAYLIGHT
END:VTIMEZONE
BEGIN:VEVENT
UID:pretalx-pts2023-9ZH9NP@cfp.pass-the-salt.org
DTSTART;TZID=CET:20230705T100000
DTEND;TZID=CET:20230705T103500
DESCRIPTION:Local file inclusion methods in PHP evolved through time\, ther
 e are 2 main objectives when exploiting them:\n- Getting a remote code exe
 cution by including files containing PHP via include() or require() functi
 ons.\n- Leak local files such as PHP sources or configuration files via fi
 le_get_contents() or file() functions for example.\n\nIn the past\, the fo
 llowing requirements had to be met to exploit a local file inclusion.\nTo 
 exploit a remote code execution you could inject information in log files 
 and include them\, or control a variable in your PHP session to poison the
  session file. But in most cases\, you needed to be able to upload a file 
 on the system.\nTo leak local files\, it was required to either fully cont
 rol the path pointing to the file to leak\, or to have a path traversal to
  go up in the file tree. Most importantly\, it was mandatory for the serve
 r to send you back its content in the response.\n\nIn both cases\, the aff
 ected functions support several wrappers\, the most iconic being file:// w
 hich is a prefix before a file path. Other wrappers such as php://filter c
 an be passed on these methods and for example it was well known to allow l
 eaking PHP sources by base64 encoding them (ex : php://filter/convert.base
 64-encode/resource=index.php). \nIn a 2021 CTF write-up by loknop \, this 
 wrapper was actually proven to be much more useful. Indeed\, it allows set
 ting the encoding of contents passing through it\, and most importantly to
  chain an infinite number of encodings leading to the generation of arbitr
 ary data at the start of a file. In this presentation\, the full process w
 ill be explained with examples allowing\, for instance\, to generate inter
 esting prefixes to a file content\, such as '<?php system("id")\; ?>'\, th
 erefore removing the need to have a file upload when exploiting include() 
 or require() functions to get remote code execution (if the full path is c
 ontrolled).\n\nIn 2022\, hash_kitten showed that it was also possible to u
 se PHP filters chain as an error-base oracle when used in many built-in fu
 nctions\, such as file_get_contents(). Its method chains encodings that wi
 ll make the content size of a file exponential\, triggering a PHP memory_l
 imit exhaustion. By using other filters\, the first character of the file 
 content can also be determined. By using other encodings it is also possib
 le to rotate the chain order to retrieve characters that are located furth
 er away in the content.\nUsing this error-based oracle\, it is therefore p
 ossible to leak the entire file content without having PHP to serve it in 
 a server response.
DTSTAMP:20261111T093916Z
LOCATION:Amphitheater
SUMMARY:PHP filter chains: How to use it - Rémi Matasse (Security research
 \, Synacktiv)
URL:https://cfp.pass-the-salt.org/pts2023/talk/9ZH9NP/
END:VEVENT
END:VCALENDAR
