Exploit databaseDownload repository ZIP
GH-8c7f0e4b0e998904a1d6f7dcd99e3e7d
d-xuan/cve-2024-52510
Sources for CVE-2024-52510
1 sourcePreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars.
Repository files28
d-xuan/cve-2024-52510Revision 6c0d89756ae0
- ↑..Parent directory
- AppInfo/
- BackgroundJob/
- Connector/
- Controller/
- Db/
- Exceptions/
- Listener/
- Middleware/
- Migration/
- Settings/
- Capabilities.php
- Config.php
- E2EEPublicShareTemplateProvider.php
- E2EEnabledPathCache.php
- EncryptionManager.php
- FileService.php
- IKeyStorage.php
- IMetaDataStorage.php
- IMetaDataStorageV1.php
- KeyStorage.php
- LockManager.php
- LockManagerV1.php
- MetaDataStorage.php
- MetaDataStorageV1.php
- RollbackService.php
- RollbackServiceV1.php
- SignatureHandler.php
- UserAgentManager.php
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
apps/end_to_end_encryption/lib/RollbackServiceV1.php
PHP · 4,078 bytes<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2020 Georg Ehrke <[email protected]>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\EndToEndEncryption;
use OCA\EndToEndEncryption\AppInfo\Application;
use OCA\EndToEndEncryption\Db\LockMapper;
use OCP\Files\Config\ICachedMountFileInfo;
use OCP\Files\Config\IUserMountCache;
use OCP\Files\Folder;
use OCP\Files\IRootFolder;
use Psr\Log\LoggerInterface;
/**
* Class RollbackService
*
* @package OCA\EndToEndEncryption
*
* This is the first implementation of a rollback-service,
* which allows restoring a previous state of an e2e folder
* in case a client dies and its token expires.
*
* This implementation is rather simple approach which copies
* a folder on lock. In case of a necessary rollback, it restores
* the state from the copied folder.
*
* A more elaborate approach should keep a journal of modifications
* and only backup files when they are actually being modified / deleted.
*/
class RollbackServiceV1 {
private LockMapper $lockMapper;
private IMetaDataStorageV1 $metaDataStorage;
private FileService $fileService;
private IUserMountCache $userMountCache;
private IRootFolder $rootFolder;
private LoggerInterface $logger;
public function __construct(LockMapper $lockMapper,
IMetaDataStorageV1 $metaDataStorage,
FileService $fileService,
IUserMountCache $userMountCache,
IRootFolder $rootFolder,
LoggerInterface $logger) {
$this->lockMapper = $lockMapper;
$this->metaDataStorage = $metaDataStorage;
$this->fileService = $fileService;
$this->userMountCache = $userMountCache;
$this->rootFolder = $rootFolder;
$this->logger = $logger;
}
/**
* Rollback all locks older than given timetstamp
*
* @param int $olderThanTimestamp
* @param int|null $limit
*/
public function rollbackOlderThan(int $olderThanTimestamp, ?int $limit = null): void {
$locks = $this->lockMapper->findAllLocksOlderThan($olderThanTimestamp, $limit);
foreach ($locks as $lock) {
$mountPoints = $this->userMountCache->getMountsForFileId($lock->getId());
if (empty($mountPoints)) {
$this->lockMapper->delete($lock);
continue;
}
/** @var ICachedMountFileInfo $firstMountPoint */
$firstMountPoint = array_shift($mountPoints);
$userId = $firstMountPoint->getUser()->getUID();
try {
$userFolder = $this->rootFolder->getUserFolder($userId);
} catch (\Exception $ex) {
$this->logger->critical($ex->getMessage(), [
'exception' => $ex,
'app' => Application::APP_ID,
]);
continue;
}
if (strpos($firstMountPoint->getInternalPath(), 'files_trashbin/files/') === 0) {
$this->lockMapper->delete($lock);
continue;
}
$nodes = $userFolder->getById($lock->getId());
if (!isset($nodes[0]) || !$nodes[0] instanceof Folder) {
continue;
}
$node = $nodes[0];
// If the time that passed since the node was last modified
// is bigger than the time to live, do nothing
if ($node->getMTime() > $olderThanTimestamp) {
continue;
}
try {
$this->fileService->revertChanges($node);
$this->metaDataStorage->deleteIntermediateFile($userId, $lock->getId());
} catch (\Exception $ex) {
$this->logger->critical($ex->getMessage(), [
'exception' => $ex,
'app' => Application::APP_ID,
]);
continue;
}
$this->lockMapper->delete($lock);
}
}
}