2026-05-20 12:19:06 -03:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2026-present, the Ladybird developers.
|
|
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <ImageDecoder/Sandbox.h>
|
2026-06-09 06:00:24 -03:00
|
|
|
#include <LibSandbox/Sandbox.h>
|
|
|
|
|
#include <LibSandbox/Seccomp.h>
|
2026-05-20 12:19:06 -03:00
|
|
|
|
|
|
|
|
namespace ImageDecoder {
|
|
|
|
|
|
2026-06-09 06:00:24 -03:00
|
|
|
ErrorOr<void> apply_sandbox()
|
2026-05-20 12:19:06 -03:00
|
|
|
{
|
2026-06-09 06:00:24 -03:00
|
|
|
TRY(Sandbox::install_no_new_privileges());
|
|
|
|
|
TRY(Sandbox::configure_runtime());
|
|
|
|
|
TRY(Sandbox::restrict_filesystem_with_landlock());
|
2026-05-20 12:19:06 -03:00
|
|
|
|
2026-06-09 06:00:24 -03:00
|
|
|
Sandbox::SeccompPolicy policy;
|
|
|
|
|
policy.deny_readonly_filesystem_probes();
|
|
|
|
|
policy.allow_file_descriptor_operations();
|
|
|
|
|
policy.allow_ipc();
|
|
|
|
|
policy.allow_common_runtime();
|
|
|
|
|
TRY(policy.install());
|
2026-05-20 12:19:06 -03:00
|
|
|
|
|
|
|
|
return {};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|