首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Veracode CWE ID 311:密码问题

Veracode CWE ID 311:密码问题
EN

Stack Overflow用户
提问于 2021-09-09 18:56:32
回答 1查看 143关注 0票数 0

Veracode密码问题:CWE ID:311

Description:应用程序通过将其传递给未加密的函数来公开潜在的敏感数据。这可能允许错误地公开私有数据(如加密密钥或其他敏感信息)。

Recommendations:确保应用程序保护所有敏感数据不受不必要的暴露。

指向的错误: [NSFileManager defaultManager setAttributes:@{NSFileModificationDate: NSDate date} ofItemAtPath:path error:nil];

有什么建议,如何解决这个问题?

代码语言:javascript
复制
- (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;
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-09-17 13:02:06

尝试将具有权限的属性添加为用户名,这将限制任何人读取写入文件。

//错误指向本行

代码语言:javascript
复制
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];
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69123440

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档