Anonymous | Login
News | My View | View Issues | Roadmap | Summary

View Issue DetailsJump to Notes ] Issue History ] Print ]
TypeCategorySeverityReproducibilityDate SubmittedLast Update
backport[Openbravo ERP] C. Securitymajoralways2019-07-18 17:512019-07-26 08:31
ReporterdlescosView Statuspublic 
Assigned Toalostale 
PriorityhighResolutionfixedFixed in Version3.0PR19Q1.3
StatusclosedFix in branchFixed in SCM revisionb2497eaf692d
ProjectionnoneETAnoneTarget Version3.0PR19Q1.3
OSLinux 64 bitDatabasePostgreSQLJava version7.x
OS VersionOpenbravo Appliance 14.04Database version9.3.xAnt version1.9.x
Product Version3.0PR18Q3.5SCM revision 
Review Assigned Tocaristu
Web browser
ModulesUser Interface Application
Regression level
Regression date
Regression introduced in release
Regression introduced by commit
Triggers an Emergency PackNo

0041413: Security Issue - Path Traversal with Attachments

DescriptionAttachments are vulnerable to path traversal attack by modifiying the inpKey parameter while the file is submitted, letting the Openbravo user access the server file system and replace files.

The issue lies in the
_org.openbravo.client.application.attachment.getAttachmentDirectoryForNewAttachment_ method which does not check the _inpKeyId_ value, used to create the subdirectories in attachments.

This value is later splitted in three-characters directories (_splitPath_ method, same class). This does not prevent the user from accessing large portions of the underlying file system.

Furthermore, informations on the attachments directory location on the server can be gained by providing a non existing path, which results in the user error message displaying the attachments directory absolute path.

This implies two immediate possibilities :
- if the attachments directory is contained in the main Openbravo directory, then files in _web_ and _web/js_ and _src/{build.xml, index.jsp,...}_ can be replaced.
- On UNIX, if the attachments directory is a subdirectory of _$HOME_, _.bashrc_ can be replaced.
Steps To ReproduceThe following has been tested on the last openbravo sourceforge appliance (3.0PR18Q3.5).

Open a transaction window that provides the attachments feature, let's say _"Sales Order"_.

## Collect informations
Click __"[ Add ]"__ in the Attachments section
Choose you __test_file.txt__ file with the __"Choose File"__ button.

Click __"Submit"__ and intercept the post request to __businessUtility/TabAttachments_FS.html__ and manually update the json parameter __paramValues.inpKey()__ with some impossible path like __../../../../../../../../../__ which will become __attachments/259/../../../../../../../../../__

Then forward the updated request. This should display _"Could not move report to final destination: /opt/OpenbravoERP/attachments/259/../../../../../../../../../test_file.txt"_
You have gained informations on the attachments path.

## Replace a file on the file system
Same as above but with a valid _inpKey_ path. For example on the test appliance:
../../webjs which will be expanded to attachments/259/../../web/js.
Proposed SolutionSet the _SaveAttachmentsOldWay_ to _Y_ is an immediate solution.

A possible patch would be to update the _org.openbravo.client.application.attachment.getAttachmentDirectoryForNewAttachment_ to check the whole path does not contain the ".." substring before _FileUtils.copyFileToDirectory_ is called.
TagsNo tags attached.
Attached Files

- Relationships Relation Graph ] Dependency Graph ]
blocks defect 0041401 closedalostale Security Issue - Path Traversal with Attachments 

-  Notes
hgbot (developer)
2019-07-22 13:29

Repository: erp/backports/3.0PR19Q1.3
Changeset: b2497eaf692dc039e91863945515cb5888f55d25
Author: Asier Lostalé <asier.lostale <at>>
Date: Mon Jul 22 13:10:02 2019 +0200
URL: [^]

fixed issue 41413: incorrect attachment key management

  The changeset includes:
    * Checking key sent from customer is a valid ID
    * Check the record is readable when uploading files
    * Check there is an acutal record for a given key

M modules/org.openbravo.client.application/src/org/openbravo/client/application/attachment/
M src/org/openbravo/erpCommon/businessUtility/
caristu (developer)
2019-07-26 08:31

Reviewed + tested OK.

- Issue History
Date Modified Username Field Change
2019-07-22 12:47 alostale Type defect => backport
2019-07-22 12:47 alostale Target Version => 3.0PR19Q1.3
2019-07-22 12:49 alostale Review Assigned To => caristu
2019-07-22 12:49 alostale Assigned To platform => alostale
2019-07-22 13:29 hgbot Checkin
2019-07-22 13:29 hgbot Note Added: 0113563
2019-07-22 13:29 hgbot Status scheduled => resolved
2019-07-22 13:29 hgbot Resolution open => fixed
2019-07-22 13:29 hgbot Fixed in SCM revision => [^]
2019-07-26 08:31 caristu Note Added: 0113659
2019-07-26 08:31 caristu Status resolved => closed
2019-07-26 08:31 caristu Fixed in Version => 3.0PR19Q1.3

Copyright © 2000 - 2009 MantisBT Group
Powered by Mantis Bugtracker