create new tag
, view all tags

Security Alert: Arbitrary code execution in session files (CVE-2007-0669)

ALERT! Please join the
twiki-announce list:
To get immediate alerts of high priority security issues, please join the low-volume twiki-announce list - details at TWikiAnnounceMailingList

This advisory alerts you of a potential security issue with your TWiki installation: Local users may cause TWiki to execute arbitrary code by creating CGI session files. This advisory may affect you even if CGI sessions are disabled on your site -- please read the details below to find out if you are vulnerable.

Vulnerable Software Version

Attack Vectors

Write access to global /tmp directory (or CGI session directory, if different). This can be either directly on file level (such as on a shared host), or via an HTTP vulnerability of a third party web application.


Under the assumption that an intruder has write access to the /tmp directory (or CGI session directory), such as with a vulnerability of another web application running on the same server, it is possible to execute arbitrary Perl code with the privileges of the web server process, such as user nobody.

Severity Level

The TWiki SecurityTeam triaged this issue as documented in TWikiSecurityAlertProcess and assigned the following severity level:

  • Severity 2 issue: The TWiki installation is compromised

MITRE Name for this Vulnerability

The Common Vulnerabilities and Exposures project has assigned the name CVE-2007-0669 to this vulnerability.


Your site may be vulnerable if:

  1. You run one of the vulnerable TWiki versions, and
  2. You have not reconfigured the CGI session directory $cfg{Sessions}{Dir} to a private directory

In particular, disabling the CGI session tracking via $cfg{UseClientSessions} is not sufficient to protect against this vulnerability, since there is session cleanup code that runs regardless of whether sessions are enabled or not.


  • Restrict access to the TWiki server on file level and HTTP.
  • If on a shared host, move TWiki to a dedicated host.
  • Upgrade to TWikiRelease04x01x01 -- TWiki-4.1.1.zip (recommended)
  • Apply a hotfix indicated below.

NOTE: The hotfix is known to prevent the current attacks, but it might not be a complete fix.

Hotfix for TWiki 4.x

In configure, change $cfg{Sessions}{Dir} to a private directory (one which is only readable and writable by the user your web server is running as, and is not served as web content to remote users). The recommended fix is to make a $cfg{DataDir}/session_tmp directory owned by the user Apache is running as, change its permissions to 0700 (drwx------), and set $cfg{Sessions}{Dir} to that directory.

Upgrading to TWiki 4.1.1 is recommended; the session files are cleaned up by timestamp, i.e. no longer executed. TWiki 4.1.1 will create and use the /tmp/twiki directory by default to store the session files.

Hotfix for older TWiki versions using SessionPlugin

This section details the attack vectors, details, and countermeasures for this vulnerability as it applies to the SessionPlugin. This section does not apply to TWiki versions 4.0 and up, which use built-in session tracking.

Vulnerable software version

  • SessionPlugin 1.0 -- SessionPlugin.zip (attachment versions 1-5)
  • SessionPlugin 2.0-2.992 -- SessionPlugin.zip (attachment versions 6-8)

Attack Vectors

  • For SessionPlugin 1.000:
    • Write access to the $cfg{DataDir}/.session directory, which in some cases may be created world-writable for local users.
  • For SessionPlugin 2.0-2.992:
    • Write access to global /tmp directory. This can be either directly on file level (such as shared host), or HTTP vulnerability of a third party web application.


  • For SessionPlugin 1.000 (attachment versions 1-5 from the SessionPlugin topic):
    • Ensure that the $cfg{DataDir}/.session directory exists, is owned by the user Apache is running as, and has 0700 permissions (drwx------).
  • For SessionPlugin 2.9 (attachment versions 6-8 from the SessionPlugin topic):
    • Upgrade to SessionPlugin 2.992 (attachment version 9 from the SessionPlugin topic).

Authors and Credits

Action Plan with Timeline

# Action Date Status Who
1. User discloses vulnerability to twiki-security 2007-01-28 Done AndrewMoise
2. Developer verifies issue 2007-01-29 Done KennethLavrsen, CrawfordCurrie
3. Developer fixes code and creates hotfix 2007-01-31 Done KennethLavrsen
4. Security team creates advisory 2007-02-05 Done AndrewMoise, PeterThoeny
5. Send alert to TWikiAnnounceMailingList and TWikiDevMailingList 2007-02-06 Done PeterThoeny
6. Publish advisory in Codev web and update all related topics 2007-02-08 Done PeterThoeny
7. Issue a public security advisory (vuln@secunia.com, cert@cert.org, bugs@securitytracker.com, full-disclosure@lists.netsys.com, vulnwatch@vulnwatch.org) 2007-02-08 Done PeterThoeny

External Links

-- Contributors: AndrewMoise, KennethLavrsen, PeterThoeny - 08 Feb 2007


Some additional info:

  • Upgrade to TWiki 4.1.1 is recommended.
  • The default location of session files changed in TWiki 4.1.1, also the configuration settings:
    • TWiki 4.1.0 and below had separate $TWiki::cfg{Sessions}{Dir} and $TWiki::cfg{PassthroughDir} settings, both pointing to /tmp
    • TWiki 4.1.1 combined that into one $TWiki::cfg{TempfileDir} setting, pointing to /tmp/twiki
  • There is a known issue in TWiki 4.1.1 that under some circumstances the /tmp/twiki is not created automatically - see Bugs:Item3568

-- PeterThoeny - 08 Feb 2007

I am on a shared host, so I cannot chown (probably because I am not the superuser). I can chgrp, but only to a group I am a member of, and I don't seem to be in the same group as "www". So the end result is I can change permissions, but not ownership. So I don;t think I can implement this hotfix for 4.0.5. (I can;t use 4.1.x yet because of having Perl 5.6.5.

-- EricWoods - 10 Feb 2007

You can use this hack as a workaround: Create a maketmpdir script in the bin directory with this content:

print "Content-type: text/html\n\n";
`mkdir /home/twiki/data/tmpfiles`;
`chmod 700 /home/twiki/data/tmpfiles`;
print "done\n";

Change the path in mkdir and chmod to your server environment. Run the script from your browser. This will create a tmpfiles directory in your twiki/data directory. Delete the script. Run configure and point $TWiki::cfg{Sessions}{Dir} and $TWiki::cfg{PassthroughDir} to that directory.

-- PeterThoeny - 10 Feb 2007

Edit | Attach | Watch | Print version | History: r14 < r13 < r12 < r11 < r10 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r14 - 2007-02-19 - PeterThoeny
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2018 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.