Skip to content

Truly independent web browser

LibWebView+Hub+UI/Qt: Show that the sandbox is off in every window

Andreas Kling2a9cb17923ef
diff --git a/Documentation/CrashReports.md b/Documentation/CrashReports.md
index f00ca6a8c89..ab61763c695 100644
--- a/Documentation/CrashReports.md
+++ b/Documentation/CrashReports.md
@@ -66,9 +66,9 @@ Git metadata report an unknown revision; local source modifications and
build-machine target to reproduce.
Reports also contain the time of the crash, the browser version, platform,
-architecture, numeric kernel release, build configuration, process uptime when
-available, termination signal or exit code, signal code when available, and a
-bounded native stack. Stack frames identify their binaries by Mach-O UUID on
+architecture, numeric kernel release, build configuration, whether the sandbox
+was off, process uptime when available, termination signal or exit code, signal
+code when available, and a bounded native stack. Stack frames identify their binaries by Mach-O UUID on
macOS or ELF build ID on Linux and contain object addresses with the load
relocation removed. When a binary is also loaded in the surviving browser, its
nearest available native symbol and the offset from that symbol are included.
diff --git a/Documentation/UI/QuietDesign.md b/Documentation/UI/QuietDesign.md
index 6e5b9f0604d..426e2ddd6ef 100644
--- a/Documentation/UI/QuietDesign.md
+++ b/Documentation/UI/QuietDesign.md
@@ -577,6 +577,22 @@ settings.
- Sent or deleted rows disappear. An empty list says "No crash reports waiting".
- A "Crash report settings" link at the bottom goes to Settings → Feedback.
+### Sandbox off
+
+When Ladybird runs with `--disable-sandbox`, every window shows a bar directly below the
+toolbar (or at the top of the page area in the sidebar layouts):
+
+- 32 px plus a `divider` line below, in the `toolbar` color, so it reads as part of the
+ chrome, not as a page banner. The page starts below it.
+- The `warning` icon (16 px) and one sentence in `text`: "The sandbox is off. Websites are
+ less isolated from your computer."
+- No close button, no action button, no amber fill. It can't be dismissed, because the state
+ can't be changed from inside the browser, and it should be in every screenshot that ends
+ up in a bug report.
+- Bug reports and crash reports include "sandbox: off" in their prefilled details.
+- Nothing else changes: no badge on the Ladybird button, no tint, nothing in the address
+ field (which describes the site, not the browser).
+
### Ladybird menu
- 280 px wide, 6 px padding, 26 px rows. Groups, in order:
diff --git a/Libraries/LibWebView/Application.cpp b/Libraries/LibWebView/Application.cpp
index 37fd07305dd..0c75021e8ed 100644
--- a/Libraries/LibWebView/Application.cpp
+++ b/Libraries/LibWebView/Application.cpp
@@ -51,6 +51,7 @@
#include <LibWebView/CompositorClient.h>
#include <LibWebView/CompositorPresentationClient.h>
#include <LibWebView/CookieJar.h>
+#include <LibWebView/CrashReport.h>
#include <LibWebView/CrashReportOutbox.h>
#include <LibWebView/CrashReportStore.h>
#include <LibWebView/FontService.h>
@@ -634,6 +635,7 @@ ErrorOr<void> Application::initialize(Main::Arguments const& arguments)
// Reports belong to the profile they came from, whose own setting decides what happens to them. A temporary
// profile takes nothing over, since it would take it to its grave.
+ CrashReport::set_sandbox_is_disabled(m_browser_options.disable_sandbox);
auto& crash_report_store = CrashReportStore::the();
crash_report_store.set_directory(LexicalPath::join(profile().paths().data, "CrashReports"sv).string());
if (!profile().is_temporary()) {
diff --git a/Libraries/LibWebView/CrashReport.cpp b/Libraries/LibWebView/CrashReport.cpp
index 6f25c082ece..af589712bf1 100644
--- a/Libraries/LibWebView/CrashReport.cpp
+++ b/Libraries/LibWebView/CrashReport.cpp
@@ -27,6 +27,13 @@ namespace WebView {
using namespace Core::CrashReportData;
+static DisableSandbox s_disable_sandbox { DisableSandbox::No };
+
+void CrashReport::set_sandbox_is_disabled(DisableSandbox disable_sandbox)
+{
+ s_disable_sandbox = disable_sandbox;
+}
+
#if !defined(AK_OS_WINDOWS)
// A record keeps a description of the build that wrote it after its last frame, where the crash handler never writes,
@@ -93,6 +100,8 @@ static void append_system_description(StringBuilder& builder)
++length;
builder.appendff("Kernel release: {}\n", release.substring_view(0, length));
}
+ if (s_disable_sandbox == DisableSandbox::Yes)
+ builder.append("Sandbox: off\n"sv);
}
ByteString CrashReport::describe_current_build(ProcessType process_type)
diff --git a/Libraries/LibWebView/CrashReport.h b/Libraries/LibWebView/CrashReport.h
index 56a627e9547..2df7e5d577a 100644
--- a/Libraries/LibWebView/CrashReport.h
+++ b/Libraries/LibWebView/CrashReport.h
@@ -13,6 +13,7 @@
#include <LibCore/File.h>
#include <LibWebView/CrashReportStore.h>
#include <LibWebView/Forward.h>
+#include <LibWebView/Options.h>
#include <LibWebView/ProcessType.h>
namespace Core::CrashReportData {
@@ -38,6 +39,8 @@ public:
// What a report says of the build and system that crashed. A browser records it with its record, since a later
// launch formats the report, and that launch may be another build.
static ByteString describe_current_build(ProcessType);
+ // Reports from a browser that runs without the sandbox say so.
+ static void set_sandbox_is_disabled(DisableSandbox);
ErrorOr<void> record_build_description(StringView description);
ErrorOr<void> save(int wait_status, ByteString const& directory = CrashReportStore::the().directory(),
diff --git a/Libraries/LibWebView/CrashReportReview.cpp b/Libraries/LibWebView/CrashReportReview.cpp
index cb35ede0a94..f9bd120713f 100644
--- a/Libraries/LibWebView/CrashReportReview.cpp
+++ b/Libraries/LibWebView/CrashReportReview.cpp
@@ -83,6 +83,7 @@ ErrorOr<CrashReportReview::Report> CrashReportReview::open(ByteString const& rep
add_field("Process"sv, diagnostics.header("Process"sv));
add_field("Architecture"sv, diagnostics.header("Architecture"sv));
add_field("Git commit"sv, diagnostics.header("Git commit"sv), true);
+ add_field("Sandbox"sv, diagnostics.header("Sandbox"sv));
return report;
}
diff --git a/Libraries/LibWebView/WebCompatReport.cpp b/Libraries/LibWebView/WebCompatReport.cpp
index 3794bcc4264..8356fcfb237 100644
--- a/Libraries/LibWebView/WebCompatReport.cpp
+++ b/Libraries/LibWebView/WebCompatReport.cpp
@@ -229,7 +229,7 @@ void WebCompatReport::start_submission()
submission->start();
}
-URL::URL new_bug_report_url()
+URL::URL new_bug_report_url(DisableSandbox disable_sandbox)
{
StringBuilder url;
url.append("https://github.com/LadybirdBrowser/ladybird/issues/new?template=bug_report.yml"sv);
@@ -242,7 +242,10 @@ URL::URL new_bug_report_url()
append_field("os"sv, platform);
append_field("architecture"sv, architecture == "x86_64"sv || architecture == "AArch64"sv ? architecture : "Other"sv);
append_field("commit"sv, LADYBIRD_COMMIT);
- append_field("build-flags"sv, ByteString::formatted("Ladybird {}, {}", browser_version, build_configuration));
+ auto build_flags = ByteString::formatted("Ladybird {}, {}", browser_version, build_configuration);
+ if (disable_sandbox == DisableSandbox::Yes)
+ build_flags = ByteString::formatted("{}, sandbox: off", build_flags);
+ append_field("build-flags"sv, build_flags);
return URL::Parser::basic_parse(url.string_view()).release_value();
}
diff --git a/Libraries/LibWebView/WebCompatReport.h b/Libraries/LibWebView/WebCompatReport.h
index 0ac8ded4204..c873614782e 100644
--- a/Libraries/LibWebView/WebCompatReport.h
+++ b/Libraries/LibWebView/WebCompatReport.h
@@ -19,6 +19,7 @@
#include <LibGfx/Size.h>
#include <LibURL/URL.h>
#include <LibWebView/Forward.h>
+#include <LibWebView/Options.h>
#include <LibWebView/ReportDetail.h>
#include <LibWebView/ReportSubmission.h>
@@ -81,6 +82,6 @@ private:
};
// A new issue on GitHub, with what we know of this build already filled in.
-WEBVIEW_API URL::URL new_bug_report_url();
+WEBVIEW_API URL::URL new_bug_report_url(DisableSandbox);
}
diff --git a/Services/Hub/ConnectionFromUI.cpp b/Services/Hub/ConnectionFromUI.cpp
index 604404f53a1..6609442cd5e 100644
--- a/Services/Hub/ConnectionFromUI.cpp
+++ b/Services/Hub/ConnectionFromUI.cpp
@@ -544,6 +544,7 @@ Messages::HubServer::InitializeResponse ConnectionFromUI::initialize()
state.scripting_enabled = Application::the().scripting_enabled();
state.blocks_pop_ups = Application::the().blocks_pop_ups();
state.devtools_enabled = Application::the().devtools_enabled();
+ state.sandbox_is_disabled = options.disable_sandbox == WebView::DisableSandbox::Yes;
state.downloads = downloads();
state.urls = options.urls;
state.raw_urls = options.raw_urls;
diff --git a/Services/Hub/HubClient.ipc b/Services/Hub/HubClient.ipc
index 8812b3d2192..cbb7f01dbac 100644
--- a/Services/Hub/HubClient.ipc
+++ b/Services/Hub/HubClient.ipc
@@ -147,6 +147,7 @@ struct Hub::InitialState {
bool scripting_enabled;
bool blocks_pop_ups;
bool devtools_enabled;
+ bool sandbox_is_disabled;
Vector<Hub::DownloadState> downloads;
Vector<URL::URL> urls;
Vector<ByteString> raw_urls;
diff --git a/UI/Qt/Application.cpp b/UI/Qt/Application.cpp
index eaf37536969..275c8637c9b 100644
--- a/UI/Qt/Application.cpp
+++ b/UI/Qt/Application.cpp
@@ -21,6 +21,7 @@
#include <LibWebCommon/WebView/Utilities.h>
#include <LibWebView/AutocompleteService.h>
#include <LibWebView/CanonicalTraversable.h>
+#include <LibWebView/CrashReport.h>
#include <LibWebView/CrashReportStore.h>
#include <LibWebView/FaviconStore.h>
#include <LibWebView/HistoryStore.h>
@@ -879,6 +880,8 @@ ErrorOr<void> Application::connect_to_hub(Main::Arguments const& arguments)
create_history_store(state.data_directory, state.uses_sql_database);
// NB: Reports stay in files, which both of us read. This process keeps its own for when it crashes, and the next
// launch recovers that the same as one of the Hub's.
+ m_browser_options.disable_sandbox = state.sandbox_is_disabled ? WebView::DisableSandbox::Yes : WebView::DisableSandbox::No;
+ WebView::CrashReport::set_sandbox_is_disabled(m_browser_options.disable_sandbox);
auto& crash_report_store = WebView::CrashReportStore::the();
crash_report_store.set_directory(move(state.crash_report_directory));
if (auto result = crash_report_store.initialize_browser_crash_handler(); result.is_error())
diff --git a/UI/Qt/CMakeLists.txt b/UI/Qt/CMakeLists.txt
index 9998dcb1182..6142bc100ca 100644
--- a/UI/Qt/CMakeLists.txt
+++ b/UI/Qt/CMakeLists.txt
@@ -56,6 +56,7 @@ add_library(ladybird_impl STATIC
RemoteView.cpp
ReportReview.cpp
RestoreSessionCard.cpp
+ SandboxOffBar.cpp
ScreenshotSelectionOverlay.cpp
ScreenshotViewer.cpp
SessionHistorySnapshotStorage.cpp
diff --git a/UI/Qt/SandboxOffBar.cpp b/UI/Qt/SandboxOffBar.cpp
new file mode 100644
index 00000000000..704ff270c81
--- /dev/null
+++ b/UI/Qt/SandboxOffBar.cpp
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2026-present, the Ladybird developers.
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include <UI/Qt/Icon.h>
+#include <UI/Qt/SandboxOffBar.h>
+#include <UI/Qt/Theme.h>
+
+#include <QEvent>
+#include <QPainter>
+
+namespace Ladybird {
+
+static constexpr int BAR_HEIGHT = 32;
+static constexpr int DIVIDER_HEIGHT = 1;
+static constexpr int ICON_SIZE = 16;
+static constexpr int HORIZONTAL_INSET = 12;
+static constexpr int ICON_TEXT_SPACING = 8;
+
+static constexpr auto MESSAGE = "The sandbox is off. Websites are less isolated from your computer.";
+
+SandboxOffBar::SandboxOffBar(QWidget* parent)
+ : QWidget(parent)
+{
+ setObjectName("LadybirdSandboxOffBar");
+ setAttribute(Qt::WA_OpaquePaintEvent);
+ setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
+ setFixedHeight(BAR_HEIGHT + DIVIDER_HEIGHT);
+ setAccessibleName(MESSAGE);
+}
+
+bool SandboxOffBar::event(QEvent* event)
+{
+ switch (event->type()) {
+ case QEvent::PaletteChange:
+ case QEvent::FontChange:
+ case QEvent::LayoutDirectionChange:
+ update();
+ break;
+ default:
+ break;
+ }
+ return QWidget::event(event);
+}
+
+void SandboxOffBar::paintEvent(QPaintEvent*)
+{
+ auto const& chrome = Theme::chrome(*this);
+
+ QPainter painter(this);
+ painter.fillRect(QRect { 0, 0, width(), BAR_HEIGHT }, chrome.toolbar);
+ painter.fillRect(QRect { 0, BAR_HEIGHT, width(), DIVIDER_HEIGHT }, chrome.divider);
+
+ QRect content_rect { HORIZONTAL_INSET, 0, width() - 2 * HORIZONTAL_INSET, BAR_HEIGHT };
+ QRect icon_rect { 0, (BAR_HEIGHT - ICON_SIZE) / 2, ICON_SIZE, ICON_SIZE };
+ QRect text_rect { 0, 0, content_rect.width() - ICON_SIZE - ICON_TEXT_SPACING, BAR_HEIGHT };
+ if (layoutDirection() == Qt::RightToLeft) {
+ icon_rect.moveRight(content_rect.right());
+ text_rect.moveRight(icon_rect.left() - ICON_TEXT_SPACING - 1);
+ } else {
+ icon_rect.moveLeft(content_rect.left());
+ text_rect.moveLeft(icon_rect.right() + 1 + ICON_TEXT_SPACING);
+ }
+
+ create_chrome_icon(ChromeIcon::Warning, chrome.warning).paint(&painter, icon_rect);
+
+ painter.setPen(chrome.text);
+ auto text = fontMetrics().elidedText(MESSAGE, Qt::ElideRight, text_rect.width());
+ painter.drawText(text_rect, Qt::AlignVCenter | Qt::AlignLeading, text);
+}
+
+}
diff --git a/UI/Qt/SandboxOffBar.h b/UI/Qt/SandboxOffBar.h
new file mode 100644
index 00000000000..756fe053ffe
--- /dev/null
+++ b/UI/Qt/SandboxOffBar.h
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2026-present, the Ladybird developers.
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#pragma once
+
+#include <AK/kmalloc.h>
+
+#include <QWidget>
+
+namespace Ladybird {
+
+// The bar every window shows below its toolbar while the browser runs without the sandbox. It can't be dismissed, as
+// nothing in the browser can turn the sandbox back on.
+class SandboxOffBar final : public QWidget {
+ Q_OBJECT
+
+public:
+ AK_ALLOC_WITH_KMALLOC;
+
+ explicit SandboxOffBar(QWidget* parent = nullptr);
+
+private:
+ virtual bool event(QEvent*) override;
+ virtual void paintEvent(QPaintEvent*) override;
+};
+
+}
diff --git a/UI/Qt/TabBar.cpp b/UI/Qt/TabBar.cpp
index 2eb3952dc59..804f59a8f9e 100644
--- a/UI/Qt/TabBar.cpp
+++ b/UI/Qt/TabBar.cpp
@@ -29,6 +29,7 @@
#include <UI/Qt/Menu.h>
#include <UI/Qt/Motion.h>
#include <UI/Qt/Popover.h>
+#include <UI/Qt/SandboxOffBar.h>
#include <UI/Qt/StringUtils.h>
#include <UI/Qt/SystemAppearance.h>
#include <UI/Qt/TabBar.h>
@@ -3331,6 +3332,8 @@ TabWidget::TabWidget(WebView::IsPrivate is_private, QWidget* parent)
m_page_column_layout->setContentsMargins(0, 0, 0, 0);
m_bookmarks_bar = new BookmarksBarContainer(*m_toolbar, *m_stacked_widget, m_page_column);
m_bookmarks_bar->bar().installEventFilter(this);
+ if (Application::browser_options().disable_sandbox == WebView::DisableSandbox::Yes)
+ m_sandbox_off_bar = new SandboxOffBar(m_page_column);
m_ladybird_button = new LadybirdButton(is_private, this);
@@ -3656,6 +3659,8 @@ void TabWidget::set_tab_bar_visible(bool visible)
if (!m_tab_bar_visible)
set_vertical_tabs_hover_expanded(false);
+ if (m_sandbox_off_bar)
+ m_sandbox_off_bar->setVisible(m_tab_bar_visible);
update_tab_chrome_visibility();
update_tab_layout();
@@ -4943,10 +4948,12 @@ void TabWidget::rebuild_page_column()
add_page_to_page_column();
}
-// The bookmarks bar heads the page, unless it only shows over the page while the pointer is near the toolbar. The tab
-// performance monitor's row ends the column.
+// The bar that says the sandbox is off, if it is, and then the bookmarks bar head the page, unless the bookmarks bar
+// only shows over the page while the pointer is near the toolbar. The tab performance monitor's row ends the column.
void TabWidget::add_page_to_page_column()
{
+ if (m_sandbox_off_bar)
+ m_page_column_layout->addWidget(m_sandbox_off_bar);
if (!m_bookmarks_bar->shows_over_page())
m_page_column_layout->addWidget(m_bookmarks_bar);
m_page_column_layout->addWidget(m_stacked_widget, 1);
diff --git a/UI/Qt/TabBar.h b/UI/Qt/TabBar.h
index 399b702308c..bee01cfc942 100644
--- a/UI/Qt/TabBar.h
+++ b/UI/Qt/TabBar.h
@@ -54,6 +54,7 @@ namespace Ladybird {
class AllTabsPopover;
class LadybirdButton;
+class SandboxOffBar;
class TabMicrophoneIndicator;
class TabPreviewPopup;
@@ -454,6 +455,7 @@ private:
WindowControlsReveal* m_window_controls_reveal { nullptr };
WindowToolbar* m_toolbar { nullptr };
BookmarksBarContainer* m_bookmarks_bar { nullptr };
+ SandboxOffBar* m_sandbox_off_bar { nullptr };
QWidget* m_page_column { nullptr };
QWidget* m_toolbar_placeholder { nullptr };
bool m_toolbar_follows_page_column { false };
diff --git a/UI/Qt/WindowToolbar.cpp b/UI/Qt/WindowToolbar.cpp
index 9d89939421c..a2a81962c99 100644
--- a/UI/Qt/WindowToolbar.cpp
+++ b/UI/Qt/WindowToolbar.cpp
@@ -2013,7 +2013,7 @@ void WindowToolbar::show_feedback_popover()
m_tab->view().report_website_issue();
};
m_feedback_popover->on_report_bug = [this] {
- browser_window().new_tab_from_url(WebView::new_bug_report_url(), Web::HTML::ActivateTab::Yes, BrowserWindow::TabLocation::after_current_tab());
+ browser_window().new_tab_from_url(WebView::new_bug_report_url(Application::browser_options().disable_sandbox), Web::HTML::ActivateTab::Yes, BrowserWindow::TabLocation::after_current_tab());
};
m_feedback_popover->on_review_crash_reports = [this] {
browser_window().new_tab_from_url(URL::URL::about("crashes"sv), Web::HTML::ActivateTab::Yes, BrowserWindow::TabLocation::after_current_tab());