CREATE ANY DIRECTORY threats : PDBs and the PATH_PREFIX clause

In my last blog post  “CREATE ANY DIRECTORY”=DBA=SYSDBA ! Ouch ! i talked about the potential threat that can represent the PREPROCESSOR feature introduced in oracle 11gr2 in a consolidated environment and how to develop a systemtap live patch to help preventing that.As Frank Pachot also stated a new parameter “PDB_OS_CREDENTIAL” was introduced in oracle which is meant to prevent that in CDB databases:

“The operating system interactions that are done as the OS user name specified in the credential include:

  •     External jobs that do not already have an operating system credential specified
  •     External table pre-processors
  •     PL/SQL library executions” Ref

Still there is another threat ! As stated by Connor Mcdonald in the comment section of my previous blog post : “Similarly, giving out “create any directory” is just setting yourself up to get burned – a few nasty UTL_FILE calls against anything V$DATAFILE and whoosh…the database is gone.”

For example an administrator of one PDB can compromise data belonging to another PDB ! Or inject code in another shell script that will be executed later by a higher privileged user example : “dbhome_1/QOpatch/qopiprep.bat” used when querying  “OPATCH_XML_INV”.

What if i tell you that there is a solution in CDB databases and it’s name is “PATH_PREFIX” !

PATH_PREFIX is a propriety that we specify at PDB creation : Ref

“Use this clause to ensure that file paths for directory objects associated with the PDB are restricted to the specified directory or its subdirectories. This clause also ensures that the following files associated with the PDB are restricted to the specified directory: the Oracle XML repository for the PDB, files created with a CREATE PFILE statement, and the export directory for Oracle wallets. You cannot modify the setting of this clause after you create the PDB. This clause does not affect files created by Oracle Managed Files.”

So using this propriety all directories have to be created relatively the specified path indicated by PATH_PREFIX. (example a malicious user can no more create a directory pointing to ‘/bin’ or overwrite your data files) Feel safer no ! Let’s give it a try !

ORACLE / OEL6.6 test :

First without setting the PATH_PREFIX :


Capture 10

There is no change we can still use absolute paths !

When setting the PATH_PREFIX :


Capture 21

We can no more use absolute path !  Good that’s what we are looking for !

And yes this PDB property existed since oracle but it seem it was not working as expected as we can still use absolute paths even when it’s set. See Deiby Gomez  test in  .

ORACLE 6.6 test :

Sans titre

Capture 23

Although PATH_PREFIX is set we can still use absolute path at directory creation !

Check also LOCKDOWN PROFILE / PDB Lockdown Profile Features : ref

OS_ACCESS EXTERNAL_FILE_ACCESS Using external files or directory objects in the PDB when PATH_PREFIX is not set for the PDB

That’s it 😀

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s