Request to compile Firefox with -fpie and -pie options to fully support ASLR

For developer discussion on package requests
Message
Author
User avatar
LinuxSpring1
Posts: 274
Joined: Sun May 05, 2024 8:57 am

Request to compile Firefox with -fpie and -pie options to fully support ASLR

#1 Post by LinuxSpring1 »

I was looking at firefox that is installed from the MX Repositories and noticed that the Firefox executable is not compiled with Position-Independent Code flag. Please see the code section below for more details. Due to this firefox executable does not use the power of ASLR (Address Space Layout Randomization). This is required so that attack vectors like Buffer Overflows are prevented. Would it be possible for the MX Developers to compile the entire firefox package, i.e. including binaries and shared libs, with the required flags for upcoming releases?

Code: Select all

$ file -e elf /opt/firefox/firefox
/opt/firefox/firefox: ELF 64-bit LSB executable, x86-64, version 1 (SYSV)
$
$ readelf -h /opt/firefox/firefox
ELF Header:
  Magic:   7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 
  Class:                             ELF64
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           Advanced Micro Devices X86-64
  Version:                           0x1
  Entry point address:               0x2018dc
  Start of program headers:          64 (bytes into file)
  Start of section headers:          3640 (bytes into file)
  Flags:                             0x0
  Size of this header:               64 (bytes)
  Size of program headers:           56 (bytes)
  Number of program headers:         11
  Size of section headers:           64 (bytes)
  Number of section headers:         28
  Section header string table index: 27
The output of the first command says LSB executable and the value of the key Type in the second command is given as EXEC (Executable file), which indicates that Firefox executable is not a PIC.
For reference see the output for LibreOffice which is installed from Debian repositories given below. Over there the output of the first command says LSB pie executable and the value of the key Type in the second command is given as DYN (Position-Independent Executable file). This indicates that the binary of LibreOffice is a PIC unlike Firefox.

Code: Select all

$ file -e elf /usr/lib/libreoffice/program/soffice.bin
/usr/lib/libreoffice/program/soffice.bin: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV)
ultramarine@satyaki:~
$ readelf -h /usr/lib/libreoffice/program/soffice.bin
ELF Header:
  Magic:   7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 
  Class:                             ELF64
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              DYN (Position-Independent Executable file)
  Machine:                           Advanced Micro Devices X86-64
  Version:                           0x1
  Entry point address:               0x1090
  Start of program headers:          64 (bytes into file)
  Start of section headers:          12752 (bytes into file)
  Flags:                             0x0
  Size of this header:               64 (bytes)
  Size of program headers:           56 (bytes)
  Number of program headers:         13
  Size of section headers:           64 (bytes)
  Number of section headers:         30
  Section header string table index: 29
Also I have checked that most of the MX utilities like Boot Repair, Boot Cleanup, MX Cleanup, Date and Time, etc are compiled with the required flags to make them PIC.

User avatar
dolphin_oracle
Developer
Posts: 22681
Joined: Sun Dec 16, 2007 12:17 pm

Re: Request to compile Firefox with -fpie and -pie options to fully support ASLR

#2 Post by dolphin_oracle »

We actually package firefox binaries as provided by mozilla, so no.
http://www.youtube.com/runwiththedolphin
lenovo ThinkPad X1 Extreme Gen 4 - MX-23
FYI: mx "test" repo is not the same thing as debian testing repo.
Live system help document: https://mxlinux.org/wiki/help-antix-live-usb-system/

User avatar
LinuxSpring1
Posts: 274
Joined: Sun May 05, 2024 8:57 am

Re: Request to compile Firefox with -fpie and -pie options to fully support ASLR

#3 Post by LinuxSpring1 »

Would it be possible for MX Developers or technical architect/lead to broach this with Mozilla developers or its team? So that they can start to package binaries with the PIE option enabled? I would be a welcome step to increase the security of Firefox on Linux.

User avatar
Eadwine Rose
Administrator
Posts: 15207
Joined: Wed Jul 12, 2006 2:10 am

Re: Request to compile Firefox with -fpie and -pie options to fully support ASLR

#4 Post by Eadwine Rose »

You can open a report over at Mozilla for this. MX Developers have enough work to do after all.

https://support.mozilla.org/en-US/kb/fi ... st-mozilla
MX-23.6_x64 July 31 2023 * 6.1.0-38amd64 ext4 Xfce 4.20.0 * 8-core AMD Ryzen 7 2700
Asus TUF B450-Plus Gaming UEFI * Asus GTX 1050 Ti Nvidia 535.247.01 * 2x16Gb DDR4 2666 Kingston HyperX Predator
Samsung 870EVO * Samsung S24D330 & P2250 * HP Envy 5030

User avatar
LinuxSpring1
Posts: 274
Joined: Sun May 05, 2024 8:57 am

Re: Request to compile Firefox with -fpie and -pie options to fully support ASLR

#5 Post by LinuxSpring1 »

I checked in Mozilla's Bugzilla. Found quite a few bugs related to this, 620058, 857628, etc. In all of them it seems that Mozilla has enabled the PIE option in their CLang compiler build files about 6-8 years ago.

Also noticed that in the discussions it is mentioned that other Linux Distributions like Ubuntu, Debian, etc build their own Firefox builds and all of them are built with the PIE option set. However in the case of MX Linux that is not the case. This leaves the users of MX Linux vulnerable to buffer exploits when they use Firefox.

User avatar
Stevo
Developer
Posts: 14843
Joined: Fri Dec 15, 2006 7:07 pm

Re: Request to compile Firefox with -fpie and -pie options to fully support ASLR

#6 Post by Stevo »

Then you may wish to try Mozilla's apt repository. https://support.mozilla.org/en-US/kb/in ... efox-linux

But our current mozillabinaries packages are statically built by...Mozilla.

This is relatively new, so we may think of switching to their apt repository if it works instead of wrapping their static binaries into debs. It'd be ironic if their apt repo is actually the same exact thing we are currently doing, but hey, more time for our own packaging!

Mozilla apps are built using the Rust compiler, and require just about the most recent version, too...except for the older LTS firefox-esr version in the released Debian repos. This makes the cutting edge releases impracticable to compile except on the testing and unstable Debian development versions.

Code: Select all

$ apt policy firefox-esr
firefox-esr:
  Installed: (none)
  Candidate: 115.15.0esr-1~deb12u1
  Version table:
     115.15.0esr-1~deb12u1 500
        500 http://security.debian.org/debian-security bookworm-security/main amd64 Packages
     115.14.0esr-1~deb12u1 500
        500 http://deb.debian.org/debian bookworm/main amd64 Packages
MXPI = MX Package Installer
QSI = Quick System Info from menu
The MX Test repository is mostly backports; not the same as Debian testing

User avatar
LinuxSpring1
Posts: 274
Joined: Sun May 05, 2024 8:57 am

Re: Request to compile Firefox with -fpie and -pie options to fully support ASLR

#7 Post by LinuxSpring1 »

Stevo wrote: Mon Sep 16, 2024 2:08 pm Then you may wish to try Mozilla's apt repository. https://support.mozilla.org/en-US/kb/in ... efox-linux

But our current mozillabinaries packages are statically built by...Mozilla.

This is relatively new, so we may think of switching to their apt repository if it works instead of wrapping their static binaries into debs. It'd be ironic if their apt repo is actually the same exact thing we are currently doing, but hey, more time for our own packaging!
Just to be clear, in the Mozilla KB article page that was shared earlier there are two options mentioned to build Firefox. Firstly is the option of Install Firefox .deb package for Debian-based distributions and the second option is Install Firefox from Mozilla builds. And MX is using the first option, i.e. MX team downloads the firefox related packages from Mozilla's servers like https://packages.mozilla.org/apt/ and then hosts them inside MX Package servers. Without any modification. Is that correct?
MX Team does not use the second option, i.e. Install Firefox from Mozilla builds. Which will entail MX team to download the package and then build it for various architectures.

User avatar
Stevo
Developer
Posts: 14843
Joined: Fri Dec 15, 2006 7:07 pm

Re: Request to compile Firefox with -fpie and -pie options to fully support ASLR

#8 Post by Stevo »

We can't compile the Firefox source code on any MX version/Debian release because of the newer Rust and Cargo version build requirements. A few years back, Debian was doing backports for it, until Mozilla started really going to town on requiring the latest releases of Rust, and the backports maintainer threw up their hands and gave up.

A deb package is just an installable container for any kind of file. We just put the Mozilla-compiled packages into that container, along with some other customization and helper files, to make it easy to add to our repos.

I think I'm the only one building a fork of Firefox 24.5, called Pale Moon, from source code into Debian packages, though. That uses the the standard gcc compiler suite.

I don't know if this applies for Debian's compiled Firefox, but most Debian compiled packages are built with the aid of debhelper, which has a lot of "smarts" built into it. Some hardening is automatic depending on the compiler version, and more or less can be manually specified.

https://wiki.debian.org/Hardening
MXPI = MX Package Installer
QSI = Quick System Info from menu
The MX Test repository is mostly backports; not the same as Debian testing

User avatar
LinuxSpring1
Posts: 274
Joined: Sun May 05, 2024 8:57 am

Re: Request to compile Firefox with -fpie and -pie options to fully support ASLR

#9 Post by LinuxSpring1 »

Thanks @Stevo. So we are taking the first option. Will raise a ticket with Mozilla regarding this.

Update:
Created a post in the Mozilla community forums. Could not create an account in Mozilla Bugzilla due to which was not able to post a bug.

User avatar
siamhie
Global Moderator
Posts: 3748
Joined: Fri Aug 20, 2021 5:45 pm

Re: Request to compile Firefox with -fpie and -pie options to fully support ASLR

#10 Post by siamhie »

You could use LibreWolf (FF clone).

1. Firefox telemetry stripped.
2. Cookies and History deleted when session is closed.
3. Cache is stored in RAM and not on disk.
4. ResistFingerprinting enabled by default.
5. WebGL disabled by default.
6. Enhanced Tracking Protection in Strict mode by default.
7. Comes with uBO installed.

Code: Select all

readelf -h /usr/share/librewolf/librewolf
ELF Header:
  Magic:   7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 
  Class:                             ELF64
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              DYN (Position-Independent Executable file)
  Machine:                           Advanced Micro Devices X86-64
  Version:                           0x1
  Entry point address:               0x28690
  Start of program headers:          64 (bytes into file)
  Start of section headers:          804320 (bytes into file)
  Flags:                             0x0
  Size of this header:               64 (bytes)
  Size of program headers:           56 (bytes)
  Number of program headers:         12
  Size of section headers:           64 (bytes)
  Number of section headers:         29
  Section header string table index: 28
This is my Fluxbox . There are many others like it, but this one is mine. My Fluxbox is my best friend. It is my life.
I must master it as I must master my life. Without me, my Fluxbox is useless. Without my Fluxbox, I am useless.

Locked

Return to “Package Requests / Status”