Commit Graph

661 Commits

Author SHA1 Message Date
Thomas Lamprecht
ca27a7666a bump version to 9.0.0
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-06-02 19:35:32 +02:00
Thomas Lamprecht
9590c6bdfe auto-format code using perltidy with Proxmox style guide
using the new top-level `make tidy` target, which calls perltidy via
our wrapper to enforce the desired style as closely as possible.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-06-01 14:02:40 +02:00
Thomas Lamprecht
124e7a199b buildsys: add top-level make tidy target
See pve-common's commit 5ae1f2e ("buildsys: add tidy make target")
for details about the chosen parameters.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-06-01 13:57:35 +02:00
Thomas Lamprecht
25dd3756f9 bump version to 8.2.2
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-04-08 13:37:26 +02:00
Mira Limbeck
55ab21ecfc openid: fix groups-claim regex
The previous regex matched exactly that combination of characters,
rather than any combination of the specified ones.

Fixes: e80f840 ("openid: make groups-claim RE more restrictive")
Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com>
Link: https://lore.proxmox.com/20250408113349.165831-1-m.limbeck@proxmox.com
2025-04-08 13:36:26 +02:00
Thomas Lamprecht
0727e3f517 bump version to 8.2.1
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-04-04 19:57:20 +02:00
Thomas Lamprecht
eea851d5c0 d/control: bump versioned dependency for libpve-rs-perl
to ensure verify_authorization_code we use understands the
query_userinfo parameter.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-04-04 19:57:20 +02:00
Fiona Ebner
ef93b299eb api: password: use singular they pronoun
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2025-04-04 19:21:03 +02:00
Fiona Ebner
e0e7fc67ae api: clarify that password changes for PAM realm only apply to local node
Reported in the community forum:
https://forum.proxmox.com/threads/158518/

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2025-04-04 19:21:00 +02:00
Christoph Heiss
b10fef56c9 gitignore: add rules for dpkg build artifacts
Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2025-04-04 18:54:48 +02:00
Christoph Heiss
6e0d55a587 access: lookup: avoid reading user.cfg from cfs unnecessarily
Given that the information is only needed for case-sensitive realms,
move the read into the conditional.

No functional changes.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2025-04-04 18:54:48 +02:00
Christoph Heiss
1471e1e822 access: lookup: fix undef warning for case-insensitive realms
Originally reported in the forum [0].

This is only a cosmetic fix and has no user-visible impact, just fixing
a code warning in the syslog. Applies only for case-insensitive realms
too, where Active Directory is the only type to support that.

When looking up a non-existing username on case-insensitive realms, it
currently returns `undef`, which then causes the following warning in
the syslog:

  Use of uninitialized value $username in concatenation (.) or string at /usr/share/perl5/PVE/API2/AccessControl.pm line 303.
  authentication failure; rhost=::ffff:10.0.0.1 user= msg=user name '' is too short

This now follows the logic from the common, case-sensitive path, to just
return the original, given username (which is then later on validated in
the auth chain).

No functional changes.

[0] https://forum.proxmox.com/threads/new-ad-realm-not-working-blank-username.157859/

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2025-04-04 18:54:48 +02:00
Thomas Skinner
97795a0043 fix #4234: add library functions for openid optional userinfo request
Signed-off-by: Thomas Skinner <thomas@atskinner.net>
Tested-by: Mira Limbeck <m.limbeck@proxmox.com>
2025-04-04 16:09:14 +02:00
Fabian Grünbichler
e80f840ccc openid: make groups-claim RE more restrictive
always possible to lift, but hard to lock down after the fact..

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2025-04-04 15:13:56 +02:00
Thomas Skinner
d9582bb9b8 fix #4411: openid: add logic for openid groups support
Signed-off-by: Thomas Skinner <thomas@atskinner.net>
Tested-by: Mira Limbeck <m.limbeck@proxmox.com>
Reviewed-by: Mira Limbeck <m.limbeck@proxmox.com>
FG: fixup whitespace
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2025-04-04 15:13:56 +02:00
Fiona Ebner
4546c8df48 debian: remove outdated postinst snippet
Upgrading from a pre-PVE 6 version directly to a (current) PVE 8.x
version can never work in the first place, so the test is not needed
anymore.

The snippet was added by commit 3a98190 ("add postinst script") and
enabled by commit 243262f ("fix #2079: activate authkey rotation every
24 hours").

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2025-03-18 12:18:27 +01:00
Christoph Heiss
44657865a7 api, auth: fix two typos in user-visible description
Just two small typos in user-visible API/schema description. Fix them
up.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2024-11-22 15:45:34 +01:00
Thomas Lamprecht
de84a7894b bump version to 8.2.0
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-11-13 17:42:08 +01:00
Shannon Sterz
47b7e66764 api: enforce a minimum length of 8 on new passwords
when creating new users or updating existing passwords this new
minimum is enforced which aligns with NIST's latest recommendations
[1].

[1]: https://pages.nist.gov/800-63-4/sp800-63b.html#passwordver

Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
2024-11-11 23:10:48 +01:00
Thomas Lamprecht
84599db265 api: code-style: fix breaking up long schema descriptions
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-11-10 20:05:47 +01:00
Daniel Kral
b8b2d85fe9 tests: api: add tests for expected output of get permissions endpoint
Adds test cases for the GET permissions API endpoint to ensure that:

- users with the Sys.Audit perm can access any user's permissions
- users with the Sys.Audit perm can access any token's permissions
- users without the Sys.Audit perm can access their own permissions
- users without the Sys.Audit perm can access their token's permissions
- tokens with the Sys.Audit perm can access any user's permissions
- tokens without the Sys.Audit perm can access their own permissions

These tests also separate whether a token has the privilege-separated
property or not.

Signed-off-by: Daniel Kral <d.kral@proxmox.com>
2024-11-10 20:02:44 +01:00
Fabian Grünbichler
138ecc60fa api: permissions: allow users to check their own tokens
even if they lack Sys.Audit on /access - since tokens are self-service,
checking whether the ACLs work as expected should also be doable for every
user.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Tested-by: Daniel Kral <d.kral@proxmox.com>
2024-11-10 20:02:30 +01:00
Fabian Grünbichler
6287395114 api: permissions: allow users to view their own permissions
even when specifying an explicit userid matching their own.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Tested-by: Daniel Kral <d.kral@proxmox.com>
2024-11-10 20:02:18 +01:00
Thomas Lamprecht
37a813d721 pveum: user token: rename remove command to delete with alias
All other groups use delete for deleting users/groups/... so it makes
sense to do so for the user token command group too.

Add an alias for the old command for backwards compatibility to avoid
that scrips and muscle memory break.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-07-22 18:33:13 +02:00
Thomas Lamprecht
3f73052b19 pveum: indentation clean-up
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-07-22 18:32:37 +02:00
Fabian Grünbichler
7d05a239d2 api: ACL update: fix handling of Permissions.Modify
With the PVE 8.0 major release, the scope of
non-"Permissions.Modify"-based ACL update privileges were reduced (so
that users with for example, VM.Allocate on a VM could only delegate
their own privileges, but not arbitrary other ones). that additional
logic had a wrong guard and was accidentally triggered for calls where
the user had the "Permissions.Modify" privilege on the modified ACL
path, but without propagation set.

A user with "Permissions.Modify" on a path should be able to set
arbitrary ACLs for that path, even without propagation.

Reported on the forum: https://forum.proxmox.com/threads/151032/

Fixes: 46bfd59 ("acls: restrict less-privileged ACL modifications")
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2024-07-16 18:11:20 +02:00
Thomas Lamprecht
2c74a9abd5 bump version to 8.1.4
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-04-22 13:45:27 +02:00
Daniel Krambrock via pve-devel
cca4c0009e fix #5335: sort ACL entries in user.cfg
Stable sorting in user.cfg config file allows tracking changes by
checking into git or when using automation like ansible.

Signed-off-by: Daniel Krambrock <krambrock@hrz.uni-marburg.de>
Tested-by: Folge Gleumes <f.gleumes@proxmox.com>
2024-04-16 14:21:58 +02:00
Thomas Lamprecht
787e4c06e3 bump version to 8.1.3
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-03-22 14:14:39 +01:00
Christoph Heiss
bb34ca534e jobs: realm sync: fix scheduled LDAP syncs not applying attributes correctly
This was reported by a user in the forum [0].

The cause was that the user-* standard options were not registered
when the sync was called from the scheduler, resulting in the
following error:

  pvescheduler[2849]: skipping attribute mapping 'cn'->'comment' for user 'test@samba0' - no such standard option 'user-comment'

Fix this by simply importing the PVE::API2::User module, thus ensuring
the options get registered.

[0] https://forum.proxmox.com/threads/ldap-integration-comment-email-first-name-lastname.143490/

Fixes: cb93636 ("LDAP sync: improve validation of synced attributes")
Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
Reviewed-by: Fiona Ebner <f.ebner@proxmox.com>
Tested-by: Fiona Ebner <f.ebner@proxmox.com>
2024-03-22 11:48:31 +01:00
Wolfgang Bumiller
5bcf553e3a user: password change: require confirmation-password parameter
Add a new 'confirmation-password' parameter to the change-password
endpoint and require non-root users to confirm their passwords.

Doing so avoids that an attacker that has direct access to a computer
where a user is logged in to the PVE interface can change the password
of said user and thus either prolong their possibility to attack,
and/or create a denial of service situation, where the original user
cannot login into the PVE host using their old credentials.

Note that this might sound worse than it is, as for this attack to
work the attacker needs either:
- physical access to an unlocked computer that is currently logged in
  to a PVE host
- having taken over such a computer already through some unrelated
  vulnerability

As these required pre-conditions are pretty big implications, which
allow (temporary) access to all of the resources (including PVE ones)
that the user can control, we see this as slight improvement that
won't hurt, might protect one in some specific cases that is simply
too cheap not to do.

For now we avoid additional confirmation through a second factor,
as that is a much higher complexity without that much gain, and some
forms like (unauthenticated) button press on a WebAuthn token or the
TOTP code would be easy to circumvent in the physical access case and
in the local access case one might be able to MITM themselves too.

Reported-by: Wouter Arts <security@wth-security.nl>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
 [ TL: extend commit message ]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-03-19 17:54:29 +01:00
Wolfgang Bumiller
90faf488db return ruid in reauth_user_for_user_modification, add param name
since the upcoming use case in change_password uses the returned $ruid
and the parameter is called 'confirmation-password' there

also generalize the error so it does not mention TFA

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-03-18 11:11:07 +01:00
Wolfgang Bumiller
060941d467 move/rename root_permission_check to RPCEnvironment
now called "reauth_user_for_user_modification" since we
re-authenticate the current user while they are trying to modify
their (or others') password/tfa settings

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-03-18 10:04:28 +01:00
Wolfgang Bumiller
184a499e8a tfa: prototype fixup
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-03-18 09:21:45 +01:00
Thomas Lamprecht
85f6129773 bump version to 8.1.2
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-02-28 15:42:20 +01:00
Thomas Lamprecht
36c18144de add Sys.AccessNetwork privilege
We have some API endpoints that can access the network from the POV of
a Proxmox VE node, like e.g., the one for downloading a template/ISO
image directly to a PVE storage from an HTTP URL, and the matching
query-url-metadata that makes this functionality much more convenient
to use in the UI. But the downside of such calls is naturally that
they basically allow to scan the whole network via HTTP URLs, and
potentially even download some image that the user should not have
access to and adding to a VM that the user controls.

Due to that we limited the exposure of those API endpoints to
Sys.Modify on / (in addition to e.g. basic storage privs) for the
initial addition of the feature, as we were not sure about user
adoption and if a separate privilege could be justified.

Since we got a handful requests like #5254 this justification is now
met, so add a 'Sys.AccessNetwork' privilege.
That name should make it clear that having that privilege will allow
access to the network and the sys(tem) prefix should underline that
it's about the host systems network. Add it such, that it will only be
available for the most powerful of our built-in special roles, namely
the Administration one, besides naturally the all-powerful root@pam
special user.

Admins can then e.g. create new roles that include Sys.AccessNetwork
and Datastore.AllocateTemplate which can then be used for allowing
automation to download images while adhering to the Least Privilege
Principle.

Buglink: https://bugzilla.proxmox.com/show_bug.cgi?id=5254
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Reviewed-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2024-02-28 15:34:47 +01:00
Thomas Lamprecht
742a7b6cbd tests: split long expected-permission list over multiple lines
for a better overview and to allow slightly easier tracking of any
change, like adding a new privilege.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-02-19 15:12:23 +01:00
Thomas Lamprecht
0aa00d13a4 special roles: code-style improvements for generation of special roles
no semantic change intended

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-02-19 14:40:12 +01:00
Thomas Lamprecht
588927f14a bump version to 8.1.1
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-02-08 19:03:31 +01:00
Thomas Lamprecht
8c3bf4124c LDAP sync: fix-up assembling valid attribute set
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-02-08 19:03:10 +01:00
Thomas Lamprecht
6324cbb39c bump version to 8.1.0
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-02-08 18:20:40 +01:00
Gabriel Goller
b543394c93 oidc: enforce generic URI regex for the ACR value
Restrict the acr-value regex a little bit so as to align the behavior
with PBS. The openid documentation says that the acr-value *should* be
an URI [0]. Added a regex that loosely disallows some of the reserved
URI characters specified in the RFC [1].

Values like:
 * "urn:mace:incommon:iap:silver"
 * "urn:comsolve.nl:idp:contract:rba:location"
SHOULD work, but values like:
 * "urn:#ace:incommon:iap:silver"
 * "urn:"omsolve.nl:idp:contract:rba:location"
should NOT work.

This is related to the fix [2] for bug #5190 in PBS, but different as
there we had to make the verifier more flexible, whereas here we make
it stricter – mostly to have both projects aligned to avoid confusion.

[0]: https://openid.net/specs/openid-connect-core-1_0.html
[1]: https://www.rfc-editor.org/rfc/rfc2396.txt
[2]: https://git.proxmox.com/?p=proxmox-backup.git;a=commit;h=e0222ce83c28397d493c70825e873943c1223c67

Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
2024-02-08 18:17:04 +01:00
Thomas Lamprecht
744ec31426 api: user: limit email to 254 characters and user comment to 2048
For email the reasoning is:

>  In addition to restrictions on syntax, there is a length limit on
>  email addresses.  That limit is a maximum of 64 characters (octets)
>  in the "local part" (before the "@") and a maximum of 255
>  characters (octets) in the domain part (after the "@") for a total
>  length of 320 characters. However, there is a restriction in RFC
>  2821 on the length of an address in MAIL and RCPT commands of 254
>  characters.  Since addresses that do not fit in those fields are
>  not normally useful, the upper limit on address lengths should
>  normally be considered to be 254.
-- https://www.rfc-editor.org/errata_search.php?rfc=3696&eid=1690

And for user-comments, we normally show those as single line and using
2048 bytes as maximum, while also a rather arbitrary number it allows
for about 2.5 times more users on a system (full name + comment can be
up to 4 KiB vs 10 KiB), and we can re-raise this relatively easily
again if there are somewhat reasonable complaints.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-02-08 17:50:54 +01:00
Fiona Ebner
04712fc464 api: user: limit maximum length for certain properties
The user.cfg file resides on the cluster filesystem where files have
a maximum allowed size (currently 1 MiB).

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2024-02-08 15:59:31 +01:00
Thomas Lamprecht
793039db4d LDAP sync: bail if there is no schema to verify an attribute's value
Should not matter for now, but better to to catch explicitly, e.g., if
anybody ever adds new attributes or changes the default options names
without adapting this too.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-02-08 15:59:31 +01:00
Thomas Lamprecht
7abb20a1ea LDAP sync: build valid-target-attribute list on the fly to avoid coupling
Build the set of valid target attributes on the fly by using the
existing ldap => ours mapping. This avoids that one needs to adapt
both lists when changing this, which even though it should be caught
on testing, is needlessly adding friction.

The is-known-target-attr check could never trigger as this was already
checked in the parent before even calling the verify method, so just
remove it.

Rename the `verify_sync_attribute` to `verify_sync_attribute_value` to
clarify that it really only checks the value of an attribute, not the
attribute (key) itself.

As a side-benefit, this also makes the code shorter and avoids a
permanent global variable using up (a tiny amount of) space.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-02-08 15:58:20 +01:00
Fiona Ebner
cb93636b55 LDAP sync: improve validation of synced attributes
and skip the ones not fitting our schema, while warning the user about
them.

Also warns the user if the specified 'sync_attributes' mapping
contains entries for attributes that don't exist, e.g.
'enabled=active' (since the property on PVE side is called 'enable').

For the 'enable' property, any value coming from the server led to the
user being enabled, even "0", because it is a string. This is not
changed by this patch, by not trying to validate or parse a boolean.

In get_users(), the username is also set in the returned hash, but
without the realm. This doesn't seem to be necessary for syncing,
because the username with the realm is used as a hash key and that's
what's relied upon when updating the config. But the tests require it
to be set, so that is not changed by this patch either.

Relies on the user properties (other than username) to be standard
options called 'user-XYZ'. Could be improved by moving the schema for
user properties from the API module to a module that can be accessed
by both API and plugin here and creating a helper for accessing it.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2024-02-08 11:50:03 +01:00
Fiona Ebner
2dabf3c3ae api: user: add pattern for user keys option
While nowadays, most entries should be just 'x', there can also still
be legacy entries with 'x!u2f', 'x!yubico' and base32 encoded secrets.
For example, some users might be syncing them from LDAP.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2024-02-08 11:08:49 +01:00
Fabian Grünbichler
a53fd5d882 build: fix file list
this file is installed by a sub-dir Makefile, it does not exist in
src/PVE/API2.

the error is not fatal, but printed during build:

 install: cannot stat 'RealmSync.pm': No such file or directory

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2023-12-07 12:36:40 +01:00
Wolfgang Bumiller
ffc4e503ec bump version to 8.0.7
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-11-20 12:24:32 +01:00