Start here

Home
About Klocwork
What's new
Fixed issues
Release notes
Installation

Reference

C/C++ checkers
Java checkers
C# checkers
MISRA C 2004 checkers
MISRA C++ 2008 checkers
MISRA C 2012 checkers
MISRA C 2012 checkers with Amendment 1
Commands
Metrics
Troubleshooting
Reference

Product components

C/C++ Integration build analysis
Java Integration build analysis
Desktop analysis
Refactoring
Klocwork Static Code Analysis
Klocwork Code Review
Structure101
Tuning
Custom checkers

Coding environments

Visual Studio
Eclipse for C/C++
Eclipse for Java
IntelliJ IDEA
Other

Administration

Project configuration
Build configuration
Administration
Analysis performance
Server performance
Security/permissions
Licensing
Klocwork Static Code Analysis Web API
Klocwork Code Review Web API

Community

View help online
Visit RogueWave.com
Klocwork Support
Rogue Wave Videos

Legal

Legal information

SV.TMPFILE

This error appears when unvalidated user input enters an API for temporary file creation as a prefix, suffix or temporary directory path.

Vulnerability and risk

This situation can lead to Path Manipulation or Denial of Service. With Path Manipulation, a user can manipulate a path to a temporary file to make it available in non-protected directories, for example in web root. A user can make this method throw an IllegalArgumentException (for example, if a prefix is too short). This situation could also result in an IOException, which can cause denial-of-service (DoS) to the application, if it is not properly processed.

Klocwork security vulnerability (SV) checkers identify calls that create potentially dangerous data; these calls are considered unsafe sources. An unsafe source can be any data provided by the user, since the user could be an attacker or has the potential for introducing human error.

Mitigation and prevention

Never use user data for names of temporary files.

Example 1

15     protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
16         String name = req.getParameter("USERNAME");
17         File file = File.createTempFile(name, ".tmp");
18         dumpSensitiveInfoAndRunSomeApp(file);
19         file.delete();
20     }
21 
22     private void dumpSensitiveInfoAndRunSomeApp(File file) {
23         // ...
24     }

SV.TMPFILE is reported for line 17: 'name' contains data coming from an HTTP request parameter and might be tainted (line 16). This value is used to create the temporary file on line 17. This can be used to create temporary files in different locations, allowing access escalation or DoS.

Extension

This checker can be extended through the Klocwork knowledge base. See Tuning Java analysis for more information.