Skip to content
Path traversal Write-up Intermediate

Critical Foswiki Vulnerablities: A Logic Error Turned Remote Code Execution

A path traversal flaw in the TopicInteractionPlugin's move function allowed an authenticated user to move the AdminGroup page file and replace it with a crafted page that granted them admin rights. As an admin, they could then set a mail program to an arbitrary command, leading to remote code execution.

Christian Pöschl Follow

Published on herolab.usd.de

We love open-source software. In context of our mission #moresecurity, Christian Pöschl, security consultant and penetration tester at usd HeroLab had a look at Foswiki as a research project.

Christian Pöschl, on herolab.usd.de

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the move attachment feature did not properly validate the filename parameter, allowing directory traversal to move arbitrary files.

Impact

An authenticated user could escalate to admin and execute arbitrary system commands, but the command execution feature was intended and its risk accepted; the path traversal was fixed in TopicInteractionPlugin 9.20.

What the attacker needed

A registered user account; the TopicInteractionPlugin enabled; ability to create pages in Sandbox

The fix

The path traversal was fixed in TopicInteractionPlugin version 9.20, but the command execution feature remains as intended.

How it was found

  1. Create a new wiki page in the Sandbox with content that includes a preference allowing your user to edit the AdminGroup page.
  2. Use the move attachment feature to move the original AdminGroup.txt file to another location via a path traversal in the filename parameter.
  3. Move your crafted page to the Main/AdminGroup location, overwriting the original.
  4. Edit the AdminGroup page to add your user as a member.
  5. Access the Foswiki configuration page and enable mail settings, setting the mail program to an arbitrary command.
  6. Send a test email to trigger the command execution.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

The wiki software let users move files around, but it didn't check where the files were being moved to. A logged-in user could move a special file that controls who is an administrator, then put their own file in its place to become an admin. Once an admin, they could change a setting that runs a program when sending email, and they set that program to a command that gave them control of the server.

What is Path traversal?

Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.

Similar reports

View all

Same bug class and techniques, clearest first.

Path traversal and file inclusion

The lesson behind this report.

Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.