Skip to content

arbitrary file over write #453

Description

@turingH

I'm a security researcher from pwnzen at Shanghai,China.
First of all, thank you for your sharing .

We found that

+ (BOOL)unzipFileAtPath:(NSString *)path
          toDestination:(NSString *)destination
     preserveAttributes:(BOOL)preserveAttributes
              overwrite:(BOOL)overwrite
         nestedZipLevel:(NSInteger)nestedZipLevel
               password:(nullable NSString *)password
                  error:(NSError **)error
               delegate:(nullable id<SSZipArchiveDelegate>)delegate
        progressHandler:(void (^_Nullable)(NSString *entry, unz_file_info zipInfo, long entryNumber, long total))progressHandler
      completionHandler:(void (^_Nullable)(NSString *path, BOOL succeeded, NSError * _Nullable error))completionHandler
{
[...]
if ([strPath rangeOfCharacterFromSet:[NSCharacterSet characterSetWithCharactersInString:@"/\\"]].location != NSNotFound) {
    strPath = [strPath stringByReplacingOccurrencesOfString:@"\\" withString:@"/"];
}          
    NSString *fullPath = [destination stringByAppendingPathComponent:strPath];
[...]
}

function may lead to arbitrary file over write

In case of holding path traversal filenames in the archive, strPath should be checked for whether it contains "../../../".

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions