Veracode密码问题:CWE ID:311
Description:应用程序通过将其传递给未加密的函数来公开潜在的敏感数据。这可能允许错误地公开私有数据(如加密密钥或其他敏感信息)。
Recommendations:确保应用程序保护所有敏感数据不受不必要的暴露。
指向的错误: [NSFileManager defaultManager setAttributes:@{NSFileModificationDate: NSDate date} ofItemAtPath:path error:nil];
有什么建议,如何解决这个问题?
- (NSData*)loadContentsFromSecureFile:(NSString*)name ofType:(HCFileType)type
{
NSString *path = [self pathForFile:name ofType:type];
NSData *encryptedData = [NSData dataWithContentsOfFile:path];
if (encryptedData == nil) {
DebugLog(@"No secure data found: %@", path);
return nil;
}
NSData *data = [encryptedData AES256DecryptWithKey:[self.profile getFileKeyBytes]];
if (data == nil) {
DebugLog(@"Unable to decrypt data, deleting: %@", path);
[[NSFileManager defaultManager] removeItemAtPath:path error:nil];
return nil;
}
// Error pointed on this below line.
[[NSFileManager defaultManager] setAttributes:@{NSFileModificationDate: [NSDate date]} ofItemAtPath:path error:nil];
return data;
}发布于 2021-09-17 13:02:06
尝试将具有权限的属性添加为用户名,这将限制任何人读取写入文件。
//错误指向本行
NSDictionary *attrib = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithInt:0], NSFileGroupOwnerAccountID,
[NSNumber numberWithInt:0], NSFileOwnerAccountID,
@"username", NSFileGroupOwnerAccountName,
@"username", NSFileOwnerAccountName, NSFileModificationDate, [NSDate date]];
[[NSFileManager defaultManager] setAttributes:attrib ofItemAtPath:path error:nil];https://stackoverflow.com/questions/69123440
复制相似问题