Tiny File Manager - There's no place like home

I remember this carpet, at the entrance of the Computer Science faculty, with this message There’s no place like 127.0.0.1/8. A joke that would create two categories of people: those who got it, and those who don’t. But in reality, is 127.0.0.1 that unique ?

The loopback is actually related to the whole 127.0.0.0/8 range, which is a humongous. In other words, an address like 127.x.x.x is related to the local machine, and bound to the loopback interface. Although trying to reach a local service with the address 127.0.0.1 and 127.0.0.2 are not exactly the same, we can already see that actually, 127.0.0.1 is not that unique.

They are multiple ways to refer to a web service running on localhost using an IP address, for example (but not limited to):

  • http://127.1
  • http://127.0.1
  • http://0x7f.1
  • http://0x7f.0.0.0000000001
  • http://0177.0.0.1
  • http://0x7f000001
  • http://017700000001

But in the end (and it actually does matter), IPv4 address are still 32 bits integers, and can be written as a single number. Dots in IPv4 notation are used for convenience, one dot per each 8-bits block, but they can somehow be omitted. It means that one can write it like (127 << 24) + 1 = 2130706433, and trying to reach http://2130706433 should be the same as http://127.0.0.1. A dot-free IPv4 address can also be written as hexadecimal (0x7f000001) or even octal (017700000001).

Web applications that let users fetch content from URLs often tend to forbid requests toward 127.0.0.1 to prevent from restricted content access. Tiny File Manager does this, using the following regular expression (screenshot taken the 26.09.2023, time of writing):

TFM regex

One can see that such regular expression is not efficient to prevent from an access to local resources. The impact is still mitigated by the fact that the URL must start with http.

The regex is built as follows:

  • 1st alternative: the host is localhost
  • 2nd alternative: 127 followed by a group made of a dot and a series of number. This group can be found up to two times, and must be followed by the same group. It would therefore match strings like 127.1, 127.0.1, 127.0.0.1, but also 127.0.0.111111111111111 which is clearly not a valid IP address
  • 3rd alternative: would match ::1, the local address for IPv6.

However, 0x7f.0.0.1 or 2130706433 would bypass the regex. Relying of regular expressions to filter user inputs is often insufficient. But I guess that is not the worst to fear when deploying a Tiny File Manager :wink:

2024

Exploiting CVE-2024-37148

3 minute read

Intro When it comes to input sanitisation, who is responsible, the function or the caller ? Or both ? And if no one does, hoping that the other one will do t...

Exploiting CVE-2024-27096

7 minute read

Intro A few weeks ago, I discovered during an intrusion test two vulnerabilities affecting GLPI 10.0.12, that was the latest public version at this time. The...

Back to Top ↑

2023

From SSRF to authentication bypass

4 minute read

I won’t insult you by explaining once again what JSON Web Tokens (JWTs) are, and how to attack them. A plethora of awesome articles exists on the Web, descri...

Hidden in plain sight - Part 2

10 minute read

A few days ago, I published a blog post about PHP webshells, ending with a discussion about filters evasion by getting rid of the pattern $_. The latter is c...

I want to talk to your managed code

12 minute read

TL;DR A few experiments about mixed managed/unmanaged assemblies. To begin with, we start by presenting a C# programme that hides a part of its payload in an...

Qakbot JScript dropper analysis

11 minute read

It was a sunny and warm summer afternoon, and while normal people would rush to the beach, I decided to devote myself to one of my favourite activities: suff...

CVE-2023-3033

3 minute read

This walkthrough presents another vulnerability discovered on the Mobatime web application (see CVE-2023-3032, same version 06.7.2022 affected). This vulnera...

CVE-2023-3032

less than 1 minute read

Mobatime offers various time-related products, such as check-in solutions. In versions up to 06.7.2022, an arbitrary file upload allowed an authenticated use...

CVE-2023-3031

less than 1 minute read

King-Avis is a Prestashop module developed by Webbax. In versions older than 17.3.15, the latter suffers from an authenticated path traversal, leading to loc...

FuckFastCGI made simpler

3 minute read

Let’s render unto Caesar the things that are Caesar’s, the exploit FuckFastCGI is not mine and is a brilliant one, bypassing open_basedir and disable_functio...

PHP .user.ini risks

7 minute read

I have to admit, PHP is not my favourite, but such powerful language sometimes really amazes me. Two days ago, I found a bypass of the directive open_basedir...

PHP open_basedir bypass

3 minute read

PHP is a really powerful language, and as a wise man once said, with great power comes great responsibilities. There is nothing more frustrating than obtaini...

Back to Top ↑

2020

Self modifying C program - Polymorphic

17 minute read

A few weeks ago, a good friend of mine asked me if it was possible to create such a program, as it could modify itself. After some thoughts, I answered that ...

Back to Top ↑