qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/14] Improve mechanism for configuring allowed commands
@ 2024-06-04 15:32 Daniel P. Berrangé
  2024-06-04 15:32 ` [PATCH 01/14] qapi: use "QAPI_FEATURE" as namespace for special features Daniel P. Berrangé
                   ` (15 more replies)
  0 siblings, 16 replies; 26+ messages in thread
From: Daniel P. Berrangé @ 2024-06-04 15:32 UTC (permalink / raw)
  To: qemu-devel
  Cc: Markus Armbruster, Michael Roth, Konstantin Kostiuk,
	Daniel P. Berrangé

The QGA supports dynamically filtering what commands are enabled via a
combination of allow lists and deny lists. This is very flexible, but
at the same time very fragile.

Consider that a user wants to block all commands that allow unrestricted
file access/command execution, so they set the deny list when starting
QGA. Now their OS vendor issues a software update which includes a new
version of QGA. This new QGA version is liable to contain new commands,
some of which might undermine the intent of the user's configured deny
list.

IOW, the generic deny list functionality is inherently dangerous as a
mechanism for limiting risk exposure.

Using an allow list is much safer, but means on every update the user
should check the list of new commands to decide which are safe or not,
putting a burden on every user.

In the context of RHEL, there has been a long term deny list that blocks
use of guest-file and guest-exec commands, since they give unrestricted
access to the guest.

With the advent of confidential computing, a far greater number of QGA
commands are very unsafe to permit, and it is unreasonable to expect
each user and/or downstream vendor to repeat the work to figure out
what commands are OK.

This is a similar problem seen in the "seccomp" world where new syscalls
appear frequently and users can't be expected to understand all of them.
Systemd pioneered the approach of defining "profiles"  which group
together sets of syscalls, which we subsequently copied in QEMU.

This series applies this same conceptual idea to QGA command filtering,
making use of the QAPI "features" facility to associate commands into
one or more groups.

This grouping is then exposed via some new higher level command line
arguments.

* --no-unrestricted / -u

  A flag to block all the guest-file and guest-exec commands

  This replicates the policy RHEL currently defines via a deny list.

* --no-user-auth / -e

  A flag to block all the commands for manipulating user account
  authentication credentials.

* --confidential / -i

  A flag to block all commands, except for those which have been
  explicitly marked as not violating guest owner data privacy

This feature mechanism is further utilized internally to track the
commands which are safe to use while FS are frozen.

A key benefit of using the QAPI "features" facility is that these
groupings are visible in the documentation of the QGA commands.

By using these high level command lines arguments, deployments will
be safe wrt software upgrades, as long as QEMU maintainers apply
appropriate tags to any new commands.

The allow/deny list command line flags can still be used to further
refine the command lines, but ideally that would be rare.

A missing piece in this series is getting the --confidential flag to
be automatically passed to QGA when running in a confidential VM. This
is something that will likely be done via systemd unit files. My thought
is that the existing 'qemu-guest-agent.service' would get a parameter

   ConditionSecurity=!cvm

while a new qemu-guest-agent-confidential.service' would have the same
content but with ConditionSecurity=cvm instead, and would pass the
--confidential flag.

This series depends on the one I sent earlier:

  https://lists.nongnu.org/archive/html/qemu-devel/2024-06/msg00743.html

Daniel P. Berrangé (14):
  qapi: use "QAPI_FEATURE" as namespace for special features
  qapi: add helper for checking if a command feature is set
  qapi: cope with special feature names containing a '-'
  qapi: add a 'command-features' pragma
  qapi: stop hardcoding list of special features
  qapi: define enum for custom special features on commands
  qga: use special feature to mark those that can run when FS are frozen
  qga: add command line to limit commands for confidential guests
  qga: define commands which can be run in confidential mode
  qga: add command line to block unrestricted command/file access
  qga: mark guest-file-* commands with 'unrestricted' flag
  qga: mark guest-exec-* commands with 'unrestricted' flag
  qga: add command line to block user authentication commands
  qga: mark guest-ssh-* / guest-*-password commands with 'unrestricted'
    flag

 include/qapi/qmp/dispatch.h   |   1 +
 include/qapi/util.h           |   6 +-
 qapi/qapi-util.c              |   4 +-
 qapi/qmp-registry.c           |   5 +
 qapi/qobject-output-visitor.c |   4 +-
 qga/main.c                    |  66 ++++++---
 qga/qapi-schema.json          | 248 +++++++++++++++++++++++++++++++---
 scripts/qapi/commands.py      |  20 +++
 scripts/qapi/gen.py           |   2 +-
 scripts/qapi/parser.py        |   2 +
 scripts/qapi/schema.py        |  33 ++++-
 scripts/qapi/source.py        |   2 +
 12 files changed, 341 insertions(+), 52 deletions(-)

-- 
2.45.1



^ permalink raw reply	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2024-07-17 11:45 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-04 15:32 [PATCH 00/14] Improve mechanism for configuring allowed commands Daniel P. Berrangé
2024-06-04 15:32 ` [PATCH 01/14] qapi: use "QAPI_FEATURE" as namespace for special features Daniel P. Berrangé
2024-06-04 15:32 ` [PATCH 02/14] qapi: add helper for checking if a command feature is set Daniel P. Berrangé
2024-06-04 15:32 ` [PATCH 03/14] qapi: cope with special feature names containing a '-' Daniel P. Berrangé
2024-07-12  7:54   ` Markus Armbruster
2024-06-04 15:32 ` [PATCH 04/14] qapi: add a 'command-features' pragma Daniel P. Berrangé
2024-07-12  8:07   ` Markus Armbruster
2024-07-12  8:12     ` Daniel P. Berrangé
2024-07-12  8:50       ` Markus Armbruster
2024-07-12  9:17         ` Daniel P. Berrangé
2024-07-16 18:08           ` Markus Armbruster
2024-07-17 10:46             ` Daniel P. Berrangé
2024-07-17 11:43               ` Markus Armbruster
2024-06-04 15:32 ` [PATCH 05/14] qapi: stop hardcoding list of special features Daniel P. Berrangé
2024-06-04 15:32 ` [PATCH 06/14] qapi: define enum for custom special features on commands Daniel P. Berrangé
2024-06-04 15:32 ` [PATCH 07/14] qga: use special feature to mark those that can run when FS are frozen Daniel P. Berrangé
2024-06-04 15:32 ` [PATCH 08/14] qga: add command line to limit commands for confidential guests Daniel P. Berrangé
2024-06-04 15:32 ` [PATCH 09/14] qga: define commands which can be run in confidential mode Daniel P. Berrangé
2024-06-04 15:32 ` [PATCH 10/14] qga: add command line to block unrestricted command/file access Daniel P. Berrangé
2024-06-04 15:32 ` [PATCH 11/14] qga: mark guest-file-* commands with 'unrestricted' flag Daniel P. Berrangé
2024-06-04 15:32 ` [PATCH 12/14] qga: mark guest-exec-* " Daniel P. Berrangé
2024-06-04 15:32 ` [PATCH 13/14] qga: add command line to block user authentication commands Daniel P. Berrangé
2024-06-04 15:32 ` [PATCH 14/14] qga: mark guest-ssh-* / guest-*-password commands with 'unrestricted' flag Daniel P. Berrangé
2024-07-02 18:09 ` [PATCH 00/14] Improve mechanism for configuring allowed commands Daniel P. Berrangé
2024-07-15  9:52 ` Markus Armbruster
2024-07-15 10:56   ` Daniel P. Berrangé

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).