Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
J
jadx
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open-source
jadx
Commits
965fd66e
Commit
965fd66e
authored
Jan 03, 2018
by
Sergey Toshin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adds more checks for file write ops
parent
7d3caa28
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
5 deletions
+14
-5
.DS_Store
.DS_Store
+0
-0
CodeWriter.java
jadx-core/src/main/java/jadx/core/codegen/CodeWriter.java
+7
-0
SaveCode.java
jadx-core/src/main/java/jadx/core/dex/visitors/SaveCode.java
+2
-1
ZipSecurity.java
...core/src/main/java/jadx/core/utils/files/ZipSecurity.java
+5
-4
No files found.
.DS_Store
View file @
965fd66e
No preview for this file type
jadx-core/src/main/java/jadx/core/codegen/CodeWriter.java
View file @
965fd66e
...
...
@@ -3,6 +3,7 @@ package jadx.core.codegen;
import
jadx.api.CodePosition
;
import
jadx.core.dex.attributes.nodes.LineAttrNode
;
import
jadx.core.utils.files.FileUtils
;
import
jadx.core.utils.files.ZipSecurity
;
import
java.io.File
;
import
java.io.PrintWriter
;
...
...
@@ -272,10 +273,16 @@ public class CodeWriter {
}
public
void
save
(
File
dir
,
String
subDir
,
String
fileName
)
{
if
(!
ZipSecurity
.
isValidZipEntryName
(
subDir
)
||
!
ZipSecurity
.
isValidZipEntryName
(
fileName
))
{
return
;
}
save
(
dir
,
new
File
(
subDir
,
fileName
).
getPath
());
}
public
void
save
(
File
dir
,
String
fileName
)
{
if
(!
ZipSecurity
.
isValidZipEntryName
(
fileName
))
{
return
;
}
save
(
new
File
(
dir
,
fileName
));
}
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/SaveCode.java
View file @
965fd66e
...
...
@@ -4,6 +4,7 @@ import jadx.api.IJadxArgs;
import
jadx.core.codegen.CodeWriter
;
import
jadx.core.dex.nodes.ClassNode
;
import
jadx.core.utils.exceptions.CodegenException
;
import
jadx.core.utils.files.ZipSecurity
;
import
java.io.File
;
...
...
@@ -25,7 +26,7 @@ public class SaveCode extends AbstractVisitor {
public
static
void
save
(
File
dir
,
IJadxArgs
args
,
ClassNode
cls
)
{
CodeWriter
clsCode
=
cls
.
getCode
();
String
fileName
=
cls
.
getClassInfo
().
getFullPath
()
+
".java"
;
if
(
args
.
isFallbackMode
())
{
if
(
args
.
isFallbackMode
())
{
fileName
+=
".jadx"
;
}
clsCode
.
save
(
dir
,
fileName
);
...
...
jadx-core/src/main/java/jadx/core/utils/files/ZipSecurity.java
View file @
965fd66e
...
...
@@ -10,7 +10,7 @@ public class ZipSecurity {
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
ZipSecurity
.
class
);
// size of uncompressed zip entry shouldn't be bigger of compressed in MAX_SIZE_DIFF times
private
static
final
int
MAX_SIZE_DIFF
=
5
;
private
static
final
int
MAX_SIZE_DIFF
=
10
;
private
static
boolean
isInSubDirectory
(
File
base
,
File
file
)
{
if
(
file
==
null
)
{
...
...
@@ -32,11 +32,11 @@ public class ZipSecurity {
if
(
isInSubDirectory
(
currentPath
,
canonical
))
{
return
true
;
}
LOG
.
debug
(
"Path traversal attack detected, invalid name: {}"
,
entryName
);
LOG
.
error
(
"Path traversal attack detected, invalid name: {}"
,
entryName
);
return
false
;
}
catch
(
Exception
e
)
{
LOG
.
debug
(
"Path traversal attack detected, invalid name: {}"
,
entryName
);
LOG
.
error
(
"Path traversal attack detected, invalid name: {}"
,
entryName
);
return
false
;
}
}
...
...
@@ -48,7 +48,8 @@ public class ZipSecurity {
return
true
;
}
if
(
compressedSize
*
MAX_SIZE_DIFF
<
uncompressedSize
)
{
LOG
.
debug
(
"Zip bomp attack detected, invalid sizes: compressed {}, uncompressed {}"
,
compressedSize
,
uncompressedSize
);
LOG
.
error
(
"Zip bomp attack detected, invalid sizes: compressed {}, uncompressed {}, name {}"
,
compressedSize
,
uncompressedSize
,
entry
.
getName
());
return
true
;
}
return
false
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment