Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions flutter/shell/platform/tizen/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,14 @@ config("flutter_tizen_config") {
"${sysroot_path}/usr/include/efl-1",
"${sysroot_path}/usr/include/eina-1",
"${sysroot_path}/usr/include/eina-1/eina",
"${sysroot_path}/usr/include/eldbus-1",
"${sysroot_path}/usr/include/eo-1",
"${sysroot_path}/usr/include/feedback",
"${sysroot_path}/usr/include/system",
"${sysroot_path}/usr/include/tzsh",
"${sysroot_path}/usr/include/vconf",
"${sysroot_path}/usr/include/wayland-extension",
"${sysroot_path}/usr/include/glib-2.0",
"${sysroot_path}/usr/lib/glib-2.0/include",
]

cflags_cc = [
Expand Down Expand Up @@ -117,7 +118,7 @@ template("embedder") {
"ecore_input",
"ecore_wl2",
"eina",
"eldbus",
"gio-2.0",
"feedback",
"flutter_engine",
"tbm",
Expand Down
97 changes: 62 additions & 35 deletions flutter/shell/platform/tizen/channels/accessibility_channel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,44 +22,65 @@ constexpr char kAtspiDirectReadInterface[] = "org.tizen.DirectReading";

} // namespace

static void _accessibilityBusAddressGet(void* data,
const Eldbus_Message* message,
Eldbus_Pending* pending) {
Eldbus_Connection** accessibility_bus =
static_cast<Eldbus_Connection**>(data);
const char* error_name = nullptr;
const char* error_message = nullptr;
const char* socket_address = nullptr;

if (eldbus_message_error_get(message, &error_name, &error_message)) {
FT_LOG(Error) << "Eldbus message error. (" << error_name << " : "
<< error_message << ")";
static void _accessibilityBusAddressGet(GObject* source_object,
GAsyncResult* res,
gpointer user_data) {
g_autoptr(GError) error = nullptr;
g_autoptr(GVariant) result = nullptr;
GDBusConnection** accessibility_bus =
static_cast<GDBusConnection**>(user_data);

GDBusProxy* proxy = G_DBUS_PROXY(source_object);
result = g_dbus_proxy_call_finish(proxy, res, &error);

if (error) {
FT_LOG(Error) << "GDBus message error: " << error->message;
return;
}

if (!eldbus_message_arguments_get(message, "s", &socket_address) ||
!socket_address) {
const gchar* socket_address = nullptr;
if (g_variant_is_of_type(result, G_VARIANT_TYPE("(s)"))) {
g_variant_get(result, "(&s)", &socket_address);
}

if (!socket_address) {
FT_LOG(Error) << "Could not get A11Y Bus socket address.";
return;
}
*accessibility_bus = eldbus_private_address_connection_get(socket_address);

*accessibility_bus = g_dbus_connection_new_for_address_sync(
socket_address, G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT, nullptr,
nullptr, &error);

if (error) {
FT_LOG(Error) << "Failed to connect to A11Y Bus: " << error->message;
}
}

AccessibilityChannel::AccessibilityChannel(BinaryMessenger* messenger)
: channel_(std::make_unique<BasicMessageChannel<EncodableValue>>(
messenger,
kChannelName,
&StandardMessageCodec::GetInstance())) {
eldbus_init();
g_autoptr(GError) error = nullptr;
session_bus_ = g_bus_get_sync(G_BUS_TYPE_SESSION, nullptr, &error);
if (error) {
FT_LOG(Error) << "Failed to get session bus: " << error->message;
return;
}

session_bus_ = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SESSION);
bus_ = eldbus_object_get(session_bus_, kAccessibilityDbus,
kAccessibilityDbusPath);
bus_ = g_dbus_proxy_new_sync(session_bus_, G_DBUS_PROXY_FLAGS_NONE, nullptr,
kAccessibilityDbus, kAccessibilityDbusPath,
kAccessibilityDbusInterface, nullptr, &error);

Eldbus_Message* method = eldbus_object_method_call_new(
bus_, kAccessibilityDbusInterface, "GetAddress");
eldbus_object_send(bus_, method, _accessibilityBusAddressGet,
&accessibility_bus_, 100);
if (error) {
FT_LOG(Error) << "Failed to create proxy: " << error->message;
return;
}

g_dbus_proxy_call(bus_, "GetAddress", nullptr, G_DBUS_CALL_FLAGS_NONE, -1,
nullptr, (GAsyncReadyCallback)_accessibilityBusAddressGet,
&accessibility_bus_);

channel_->SetMessageHandler([&](const auto& message, auto reply) {
if (std::holds_alternative<EncodableMap>(message)) {
Expand All @@ -72,14 +93,11 @@ AccessibilityChannel::AccessibilityChannel(BinaryMessenger* messenger)
if (*type == "announce" && data) {
EncodableValueHolder<std::string> msg(data.value, "message");
if (msg && accessibility_bus_) {
Eldbus_Message* eldbus_message = eldbus_message_method_call_new(
kAtspiDirectReadBus, kAtspiDirectReadPath,
kAtspiDirectReadInterface, "ReadCommand");
Eldbus_Message_Iter* iter = eldbus_message_iter_get(eldbus_message);
eldbus_message_iter_arguments_append(iter, "sb", msg->c_str(),
true);
eldbus_connection_send(accessibility_bus_, eldbus_message, nullptr,
nullptr, -1);
GVariant* params = g_variant_new("(sb)", msg->c_str(), TRUE);
g_dbus_connection_call(
accessibility_bus_, kAtspiDirectReadBus, kAtspiDirectReadPath,
kAtspiDirectReadInterface, "ReadCommand", params, nullptr,
G_DBUS_CALL_FLAGS_NONE, -1, nullptr, nullptr, nullptr);
Comment on lines 94 to +100

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security-high high

The msg variable, which can contain untrusted input from the Flutter engine, is directly used in a D-Bus method call to ReadCommand. This could lead to command injection if the accessibility service interprets the input as commands. Implement robust input validation and sanitization for msg before it is used in the D-Bus method call. Ensure that the ReadCommand method on the org.tizen.DirectReading interface is designed to handle untrusted input securely, or consider implementing an allow-list for acceptable commands or data patterns. If possible, avoid directly passing unsanitized user input to system-level commands or interfaces.

}
}
}
Expand All @@ -91,11 +109,20 @@ AccessibilityChannel::AccessibilityChannel(BinaryMessenger* messenger)
AccessibilityChannel::~AccessibilityChannel() {
channel_->SetMessageHandler(nullptr);

eldbus_connection_unref(accessibility_bus_);
eldbus_connection_unref(session_bus_);
eldbus_object_unref(bus_);
if (accessibility_bus_) {
g_object_unref(accessibility_bus_);
accessibility_bus_ = nullptr;
}

eldbus_shutdown();
if (session_bus_) {
g_object_unref(session_bus_);
session_bus_ = nullptr;
}

if (bus_) {
g_object_unref(bus_);
bus_ = nullptr;
}
}

} // namespace flutter
8 changes: 4 additions & 4 deletions flutter/shell/platform/tizen/channels/accessibility_channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#ifndef EMBEDDER_ACCESSIBILITY_CHANNEL_H_
#define EMBEDDER_ACCESSIBILITY_CHANNEL_H_

#include <Eldbus.h>
#include <gio/gio.h>

#include <functional>
#include <memory>
Expand All @@ -23,9 +23,9 @@ class AccessibilityChannel {
private:
std::unique_ptr<BasicMessageChannel<EncodableValue>> channel_;

Eldbus_Connection* session_bus_ = nullptr;
Eldbus_Connection* accessibility_bus_ = nullptr;
Eldbus_Object* bus_ = nullptr;
GDBusConnection* session_bus_ = nullptr;
GDBusConnection* accessibility_bus_ = nullptr;
GDBusProxy* bus_ = nullptr;
};

} // namespace flutter
Expand Down
3 changes: 1 addition & 2 deletions tools/generate_sysroot.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,9 @@
'eina',
'eina-devel',
'eina-tools',
'eldbus',
'eldbus-devel',
'eo-devel',
'glib2-devel',
'libgio',
'jsoncpp',
'jsoncpp-devel',
'libatk',
Expand Down