You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by GitBox <gi...@apache.org> on 2021/06/03 02:35:28 UTC

[GitHub] [cloudstack] lujiefsi edited a comment on pull request #5066: CLOUDSTACK-10436:remind users to use correct permission for tmp dir

lujiefsi edited a comment on pull request #5066:
URL: https://github.com/apache/cloudstack/pull/5066#issuecomment-853515133


   Hi @rhtyd  Yes, most  the template related registration and operations actually run in ssvm which is not generally accessible.  what I concern is below code:
   
     protected boolean swiftUploadMetadataFile(SwiftTO swift, File srcFile, String containerName, String uniqueName) throws IOException {
   
           File uniqDir = _storage.createUniqDir();
           String metaFileName = uniqDir.getAbsolutePath() + File.separator + _tmpltpp;
           _storage.create(uniqDir.getAbsolutePath(), _tmpltpp);// metafile is created
   
           long virtualSize = getVirtualSize(srcFile, getTemplateFormat(srcFile.getName()));
   
           File metaFile = swiftWriteMetadataFile(metaFileName, uniqueName, srcFile.getName(), srcFile.length(), virtualSize);///metafile is written with uniquename,filename,size,virtualsize
   
           SwiftUtil.putObject(swift, metaFile, containerName, _tmpltpp);
           metaFile.delete();
           uniqDir.delete();
   
           return true;
       }
   
   are the uniquename,filename,size and virtualsize  sensitive? If not, that's ok. But i still think we need follow The Principle of Least Privilege (PoLP), see https://www.cyberark.com/what-is/least-privilege/
   
   I also still have another concern, that is if others take JavaStorageLayer as library for future, thay maybe not aware that the tmp dir created by createUniqDir is worldreadable.
   
   
   Meanwhile, i give a new commit to fix the potential NPE when the tmp dir does not exist. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org