On 22-04-2026 20:35, Nikolaus Kern wrote:
> Hello Mark,
>
> can you please explain what the minimum access of an attacker needs to
> be in this scenario?
> 1. Access to the firebird server as RDB$ADMIN?
Access with a user with CREATE FUNCTION, CREATE PROCEDURE, or CREATE
TRIGGER privilege to define a UDR and
1) Sufficient knowledge to be aware of the location of a pre-existing
exploitable library on your system,
or
2) CREATE TABLE privilege to define an external table (assuming
ExternalFileAccess is not None), and that it's possible to construct a
relative path between the plugins directory and the external table file.
or
3) Some other means to inject a file on the system that is knowable or
guessable (e.g. a web app that uploads files to some known, or otherwise
discoverable location)
For 1, 2 and 3, the location needs to be readable by Firebird, 2 also
needs to be writeable by Firebird.
So, yes RDB$ADMIN will have those privileges, but even less privileged
users might have sufficient privileges to pull this off, as long as they
have CREATE FUNCTION/PROCEDURE/TRIGGER and maybe CREATE TABLE.
> 2. Access to the filesystem of the firebird server?
You don't need full access, you just need to know of, or be able to
create a suitable file somewhere that is readable by Firebird.
That is easy enough if you have CREATE TABLE privilege and
ExternalFileAccess is not None. And you need to know where the external
table file can (or will) end up, so you can create a relative path
between the two. And you can probe that by constructing a pathless
external table file with illegal characters in the filename (e.g. just
'.' on Linux, '<' on Windows, I think (right now no Windows available to
check)), and then insert into it, as Firebird will then report the error
with the path where it tried to create the file, which will be the first
location listed in Restrict, or some default location (which might not
work if the config is actually None (default), but will work if it's Full).
And constructing a relative path is trivial: just add (more than) enough
../ sections to reach the root or beyond (which will also end up in the
root) and work back from there. On Windows this might still fail if the
plugins directory is on a different drive from the external table file
though (not sure if there might be some tricks to work around that).
And if you wonder "how can I create an arbitrary file with an external
table"? It's a binary format, and - for example - if you use a column of
BINARY(1) (CHAR(1) CHARACTER SET OCTETS), you can write a file one byte
per insert. Using a BINARY column sized for the whole file, or - if the
file is bigger than 32767 bytes - multiple tables with differing column
lengths pointing to the same file will make it quicker.
Mark
--
Mark Rotteveel