Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
multimedia-security-considerations.qdoc
Go to the documentation of this file.
1// Copyright (C) 2026 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
3
4/*!
5\page qtmultimedia-security-considerations.html
6\title Multimedia Security Considerations
7\brief Multimedia security considerations, including security-related data flow and risks.
8\ingroup explanations-graphicsandmultimedia
9
10\section1 Data Flow Diagram
11
12The diagram shows high-level data-processing elements in Qt Multimedia that contribute to
13secure handling of untrusted media sources.
14
15\image security_related_data_flow.webp {Security-Related Data Flow}
16
17\section1 Assumptions
18
19Like the rest of Qt, Qt Multimedia assumes that the environment it runs in is correctly
20configured and has not been compromised. In particular, the process environment, the search
21paths from which libraries and plugins are loaded, and the installed hardware-decoding drivers
22are assumed to be controlled by whoever deploys the application, and not by an attacker.
23Attacks that require an already insecure process environment fall outside the scope of Qt's
24security responsibility, as described in \l{Qt Shared Security Model}.
25
26The media content itself is not covered by that assumption. Media data, and the URLs that refer
27to it, are treated as untrusted input, and are the subject of the rest of this page. See also
28\l{Handling Untrusted Data}.
29
30Some of the points below are therefore listed not because Qt Multimedia defends against them,
31but because they are the responsibility of the application developer and need to be accounted
32for when an application is deployed.
33
34\section1 Risks
35
36In theory, if an application allows users to play untrusted media sources and an attacker is
37aware of a vulnerability in any element shown in the figure above, they may craft a media source
38that triggers the vulnerability and provide it to the application in the intended manner.
39
40The risks below are grouped by who is responsible for addressing them, following the roles
41defined in \l{Qt Shared Security Model}.
42
43\section2 Risks addressed by Qt
44
45\list
46\li Vulnerabilities in third-party libraries shipped with Qt Multimedia. Qt Multimedia does not
47 attempt to contain a compromised third-party library, so keeping those libraries up to date
48 is what protects the application. We track vulnerabilities reported against the libraries
49 we ship, update them as patch releases become available, and report the defects we find
50 ourselves to the upstream projects.
51\li Flaws in Qt Multimedia's own data flow elements that may result in undefined behavior. The
52 most sensitive area is data layout processing of native and backend media frames. We follow
53 established secure coding practices, cover this code with manual and automated tests, and
54 fuzz test Qt Multimedia internally to find defects that those tests do not reach.
55\endlist
56
57\section2 Risks addressed by the application developer
58
59\list
60\li Several Qt Multimedia APIs take a URL as their source or destination, and perform file
61 system or network access on the application's behalf. This includes
62 \l{QMediaPlayer::setSource}, \l{QAudioDecoder::setSource}, \l{QSoundEffect::setSource}, and
63 \l{QMediaRecorder::setOutputLocation}. Passing an unvalidated URL to these APIs therefore
64 lets whoever controls that URL decide which files are read or written, and which hosts
65 are contacted.
66\li With the GStreamer media backend, passing a malicious custom GStreamer pipeline description
67 to \l{QGStreamerVideoSource} or \l{QMediaPlayer}. We highly recommend never running an
68 untrusted GStreamer media pipeline with Qt Multimedia unless you can
69 meaningfully preprocess and validate GStreamer pipeline descriptions.
70\li A media backend is only used if its plugin can actually be loaded. The FFmpeg media
71 backend links dynamically against the FFmpeg libraries, so if those binaries are not
72 deployed with the application, or cannot be resolved by the dynamic linker when the plugin
73 is loaded, Qt Multimedia falls back to another available backend without warning. The
74 remaining backends are tried in the order in which their plugins are enumerated, rather
75 than in a documented order of preference, so a deployment mistake can leave the
76 application running on a backend that was never tested for it. If no backend can be
77 loaded at all, only \l{QMediaDevices}, \l{QAudioDevice}, \l{QSoundEffect},
78 \l{QAudioSink}, and \l{QAudioSource} remain functional.
79\li On Android, the FFmpeg media backend verifies \c{https} media sources against the CA
80 certificates of the application's default trust configuration, but does not otherwise
81 apply the application's \l{https://developer.android.com/privacy-and-security/security-config}
82 {Network Security Configuration}. Domain-specific trust anchors (\c{<domain-config>}),
83 Certificate Transparency requirements, and \c{cleartextTrafficPermitted="false"} are
84 ignored for media sources. To prevent cleartext media traffic, accept only \c{https}
85 URLs and restrict the allowed protocols as described in
86 \l{Configuring allowed network protocols}. If the application needs domain-specific
87 trust anchors or Certificate Transparency for its media hosts, it has to download the
88 media itself using an Android network API that applies the Network Security
89 Configuration, and pass the data to \l{QMediaPlayer::setSourceDevice}.
90\endlist
91
92\section2 Risks that depend on the operating environment
93
94These risks arise from the environment that the application runs in, rather than from Qt
95Multimedia itself, and Qt Multimedia can neither detect nor prevent them. The application
96developer needs to account for them when the application is deployed.
97
98\list
99\li Incorrect environment configuration or hardware-decoding driver setup. Ensure that
100 the environment is configured correctly and that the hardware-decoding drivers are properly
101 installed and up to date.
102\li Qt Multimedia selects its media backend at runtime, and the selection can be overridden
103 with the \c{QT_MEDIA_BACKEND} environment variable, as described in
104 \l{Changing backends}. Anyone who can influence the environment of the application
105 process can therefore make the application run on a different media backend than the one
106 it was developed and tested against, with a different set of supported formats and
107 protocols, and a different attack surface.
108\endlist
109
110\section1 Impact
111
112Exploitation of the issues listed above may lead to the following security consequences:
113
114\list
115\li Undefined behavior, practically leading to memory leaks, application crashing, or freezing.
116\li Remote code execution might be possible whenever an attacker can meaningfully control
117 heap corruption.
118\li For media formats such as \c{m3u}, which allow different protocols to be used in playlist
119 entries, a wrong setup may allow an attacker to read the file system or contact arbitrary
120 network hosts. By default, potentially dangerous protocols are denylisted, but this
121 behaviour can be changed through any of the following:
122 \list
123 \li Environment configuration. See \l{Configuring allowed network protocols} for the
124 FFmpeg media backend.
125 \li GStreamer custom pipeline. See the \l{Qt Multimedia GStreamer backend} notes,
126 \l{QGStreamerVideoSource}, and the
127 \l{https://gstreamer.freedesktop.org/documentation/tools/gst-launch.html?gi-language=c#pipeline-description}
128 {GStreamer pipeline description documentation} for details.
129 \li A media backend other than the ones shipped with Qt Multimedia. The media backend is
130 loaded as a plugin at runtime, so a backend plugin found in the application's plugin
131 search paths, or a replaced FFmpeg binary found in its library search paths, applies
132 whichever protocol restrictions it was built with rather than the defaults above.
133 \endlist
134\endlist
135
136Note that, depending on the media format, even a valid media source does not necessarily
137conform strictly to the relevant media standard. There are also many ways in which a source
138can be corrupted or made invalid.
139Despite the manual and automated testing performed on Qt Multimedia and third-party libraries
140by their respective communities, we cannot guarantee correct handling of every single
141malformed media source. Take this limitation into account when developing applications
142with advanced security requirements.
143
144\section1 Mitigations
145
146\list
147\li Treat any URL that does not originate from the application itself as untrusted input, and
148 validate it before passing it to Qt Multimedia. Prefer an allowlist of accepted URL schemes
149 and hosts over a denylist of rejected ones. If the application already has the media data,
150 or can obtain it itself, \l{QMediaPlayer::setSourceDevice} keeps the application in control
151 of how the data is read.
152\li Restrict the protocols that the media backend is allowed to use. For the FFmpeg media
153 backend, see \l{Configuring allowed network protocols} in
154 \l{Advanced FFmpeg Configuration}.
155\li Control which media backend the deployed application is able to use. Deploying only the
156 media backend plugin that the application needs is the effective control here, because it
157 leaves \c{QT_MEDIA_BACKEND} no other plugin to select. Note that choosing a different
158 default backend does not help on its own: \c{QT_MEDIA_BACKEND} takes precedence over the
159 default, including over a default set with the \c{-default-media-backend} configure option
160 when Qt Multimedia itself is built from source.
161\li Confirm as part of deployment testing that the application actually runs on the intended
162 media backend. The \c{qt.multimedia.plugin} logging category reports which backend was
163 loaded, and which plugins failed to load before it.
164\li The Qt Multimedia binaries shipped with the Qt Online Installer are dynamically linked
165 against the FFmpeg libraries \c{avcodec}, \c{avutil}, \c{avformat}, \c{swscale},
166 and \c{swresample}. An application developer or an end user can therefore deploy their own
167 binary-compatible builds of these libraries - that is, builds of the same FFmpeg major
168 version - in order to address FFmpeg vulnerabilities without waiting for a Qt patch release.
169\endlist
170
171*/