Commit Graph

2661 Commits

Author SHA1 Message Date
Kuba Wieczorek
2047ce7527 [VAULT-22480] Add audit fallback device (#24583)
Co-authored-by: Peter Wilson <peter.wilson@hashicorp.com>
2024-01-08 13:57:43 +00:00
Tom Proctor
6e537bb376 Support reloading database plugins across multiple mounts (#24512)
* Support reloading database plugins across multiple mounts
* Add clarifying comment to MountEntry.Path field
* Tests: Replace non-parallelisable t.Setenv with plugin env settings
2024-01-08 12:21:13 +00:00
Steven Clark
ade75bcf00 Update licensing across various source files (#24672) 2024-01-04 12:59:46 -05:00
Violet Hynes
75d0581464 VAULT-8790 Ensure time.NewTicker never gets called with a negative value (#24402)
* Ensure time.NewTicker never gets called with a negative value

* Remove naughty newline

* VAULT-8790 review feedback
2024-01-03 15:34:41 -05:00
Steven Clark
610c8a4d38 Move Vault's customized pkcs7 fork into a shared location (#24658)
- The PKI plugin needs to use the customized pkcs7 fork
   so move it out from the aws credential plugin's package
   into a shared location
2024-01-03 12:11:44 -05:00
Austin Gebauer
43c282f15a tools: upgrades gofumpt to v0.5.0 (#24637) 2023-12-22 14:36:44 -08:00
Kuba Wieczorek
17ffe62d0d [VAULT-22481] Add audit filtering feature (#24558)
* VAULT-22481: Audit filter node (#24465)

* Initial commit on adding filter nodes for audit

* tests for audit filter

* test: longer filter - more conditions

* copywrite headers

* Check interface for the right type

* Add audit filtering feature (#24554)

* Support filter nodes in backend factories and add some tests

* More tests and cleanup

* Attempt to move control of registration for nodes and pipelines to the audit broker (#24505)

* invert control of the pipelines/nodes to the audit broker vs. within each backend

* update noop audit test code to implement the pipeliner interface

* noop mount path has trailing slash

* attempting to make NoopAudit more friendly

* NoopAudit uses known salt

* Refactor audit.ProcessManual to support filter nodes

* HasFiltering

* rename the pipeliner

* use exported AuditEvent in Filter

* Add tests for registering and deregistering backends on the audit broker

* Add missing licence header to one file, fix a typo in two tests

---------

Co-authored-by: Peter Wilson <peter.wilson@hashicorp.com>

* Add changelog file

* update bexpr datum to use a strong type

* go docs updates

* test path

* PR review comments

* handle scenarios/outcomes from broker.send

* don't need to re-check the complete sinks

* add extra check to deregister to ensure that re-registering non-filtered device sets sink threshold

* Ensure that the multierror is appended before attempting to return it

---------

Co-authored-by: Peter Wilson <peter.wilson@hashicorp.com>
2023-12-18 18:01:49 +00:00
Tom Proctor
dc5c3e8d97 New database plugin API to reload by plugin name (#24472) 2023-12-13 10:23:34 +00:00
Peter Wilson
486df81934 Audit related foibles (#24493)
* update node and pipeline registration to prevent overwriting, strip some unused bits of NewTestCluster, tweak to prevent auditing on a test that is flaking

* tidy imports
2023-12-13 09:08:02 +00:00
Steven Clark
8963ae495d PKI: Refactor storage of certificates into a common method (#24415)
- Move the copy/pasted code to store certificates into a
   common method within the PKI plugin
2023-12-07 11:51:51 -05:00
Steven Clark
cbf6dc2c4f PKI refactoring to start breaking apart monolith into sub-packages (#24406)
* PKI refactoring to start breaking apart monolith into sub-packages

 - This was broken down by commit within enterprise for ease of review
   but would be too difficult to bring back individual commits back
   to the CE repository. (they would be squashed anyways)
 - This change was created by exporting a patch of the enterprise PR
   and applying it to CE repository

* Fix TestBackend_OID_SANs to not be rely on map ordering
2023-12-07 09:22:53 -05:00
Tom Proctor
a4180c193b Refactor plugin catalog and plugin runtime catalog into their own package (#24403)
* Refactor plugin catalog into its own package
* Fix some unnecessarily slow tests due to accidentally running multiple plugin processes
* Clean up MakeTestPluginDir helper
* Move getBackendVersion tests to plugin catalog package
* Use corehelpers.MakeTestPlugin consistently
* Fix semgrep failure: check for nil value from logical.Storage
2023-12-07 12:36:17 +00:00
Steven Clark
a41852379b Document and augment tests that PKI accepts 8192 bit RSA keys (#24364)
- Noticed that our documentation was out of date, we allow 8192
   bit RSA keys to be used as an argument to the various PKI
   issuer/key creation APIs.
 - Augument some unit tests to verify this continues to work
2023-12-05 15:26:03 -05:00
Steven Clark
5781891292 PKI: Address some errors that were not wrapped properly (#24118) 2023-11-27 15:50:54 -05:00
kpcraig
9b7d06839f Add a /config/rotate-root path to the ldap auth backend (#24099) 2023-11-27 15:48:16 -05:00
Christopher Swenson
904c08e1e4 Remove runtime patch for SHA1 support in X.509 certs (#24243)
This code only executes when the Vault version is <1.11,
so is now dead code and can be removed safely.
2023-11-27 09:11:01 -08:00
Steven Clark
53040690a2 PKI: Do not set NextUpdate OCSP field when ocsp_expiry is 0 (#24192)
* Do not set NextUpdate OCSP field when ocsp_expiry is 0

* Add cl
2023-11-20 10:32:05 -05:00
Robert Hanzlík
28e3507680 allow to skip TLS check in acme http-01 challenge (#22521)
* allow to skip TLS check in acme http-01 challenge

* remove configurable logic, just ignore TLS

* add changelog

* Add test case

---------

Co-authored-by: Steve Clark <steven.clark@hashicorp.com>
2023-11-15 11:10:29 -05:00
Steven Clark
92682f33ce Address a panic when exporting RSA public keys in transit (#24054)
* Address a panic export RSA public keys in transit

 - When attempting to export the public key for an RSA key that
   we only have a private key for, the export panics with a nil
   deference.
 - Add additional tests around Transit key exporting

* Add cl
2023-11-14 09:40:37 -05:00
Robert
54bf0807c1 secrets/aws: add support for STS Session Tokens with TOTP (#23690)
* Add test coverage

* Add session_token field, deprecate security_token

* Undo auth docs

* Update api docs

* Add MFA code support

---------

Co-authored-by: Graham Christensen <graham@grahamc.com>
Co-authored-by: Sarah Chavis <62406755+schavis@users.noreply.github.com>
Co-authored-by: Austin Gebauer <34121980+austingebauer@users.noreply.github.com>
2023-11-08 17:06:28 -06:00
Nick Cabatoff
ca06412a14 Some not-yet-merged changes to go.mod have resulted in updating the Go version and toolchain, which then breaks a test compilation. The test only applies to Go version older than 1.16, which we don't have in any active branches, so I'm just removing it. (#24028) 2023-11-06 15:48:12 +00:00
Steven Clark
a10685c521 Pin curl docker image to a specific docker version instead of latest (#23763)
- Try to avoid these build failures as our proxy does seem to have
   issues around pulling images with the 'latest' tag at times.

```
acme_test.go:206:
	Error Trace:	/home/runner/actions-runner/_work/vault-enterprise/vault-enterprise/builtin/logical/pkiext/pkiext_binary/acme_test.go:206
          	        /home/runner/actions-runner/_work/vault-enterprise/vault-enterprise/builtin/logical/pkiext/pkiext_binary/acme_test.go:75
	Error:      	Received unexpected error:
				container create failed: Error response from daemon: No such image: docker.mirror.hashicorp.services/curlimages/curl:latest
	Test:       	Test_ACME/group/caddy_http_eab
	Messages:   	could not start cURL container
```
2023-10-24 10:04:23 -04:00
Steven Clark
3623dfc227 Add support for plugins to specify binary request paths (#23729)
* wip

* more pruning

* Integrate OCSP into binary paths PoC

 - Simplify some of the changes to the router
 - Remove the binary test PKI endpoint
 - Switch OCSP to use the new binary paths backend variable

* Fix proto generation and test compilation

* Add unit test for binary request handling

---------

Co-authored-by: Scott G. Miller <smiller@hashicorp.com>
2023-10-23 17:04:42 -04:00
Hamid Ghaf
87376a1f5c Normalize error response messages when invalid credentials are provided (#23786)
* Normalize error response messages when invalid credentials are provided

* CL

* Update changelog/23786.txt

Co-authored-by: Violet Hynes <violet.hynes@hashicorp.com>

---------

Co-authored-by: Peter Wilson <peter.wilson@hashicorp.com>
Co-authored-by: Violet Hynes <violet.hynes@hashicorp.com>
2023-10-23 15:59:26 +00:00
davidadeleon
72d66e2813 Fix consul token revocation with namespace and admin partition specific policies (#23010)
* fix lease revocation when config token exists in one namespace but can create tokens in another

* add test

* Add similar check for admin partition

* Add admin partition test

---------

Co-authored-by: robmonte <17119716+robmonte@users.noreply.github.com>
2023-10-20 13:06:20 -05:00
modrake
eca4b4d801 Relplat 897 copywrite fixes for mutliple licenses (#23722) 2023-10-20 08:40:43 -07:00
Steven Clark
d0501db90f Forbid setting auto_rotate_period on transit managed keys (#23723)
* Forbid setting auto_rotate_period on transit managed keys

 - Prevent and guard against auto-rotating managed keys as we
   generate an invalid key version without the uuid field set.
 - Hook in the datakey generation api into managed key encryption.

* Add cl
2023-10-19 15:29:01 -04:00
kpcraig
6aabb22b7c AWS Static Secrets: Requeue credential for rotation if initial attempt fails (#23673) 2023-10-17 14:12:33 -04:00
Steven Clark
bc4be73a1c Fix Transit managed key fixes - OSS (#23676)
- This is the OSS parts of the greater enterprise PR to address some
   issues with signing and encryption within Transit using managed keys.
2023-10-16 15:52:59 -04:00
kpcraig
30f19b383f VAULT-18307: update rotation period for aws static roles on update (#23528) 2023-10-11 17:06:58 +00:00
Peter Wilson
88fb88e3db Audit: eventlogger sink node reopen on SIGHUP (#23598)
* ensure nodes are asked to reload audit files on SIGHUP

* added changelog
2023-10-11 16:46:49 +01:00
Robert
8202c7db4b auth/aws: fix panic in IAM-based login when client config doesn't exist (#23555)
Co-authored-by: Austin Gebauer <34121980+austingebauer@users.noreply.github.com>
2023-10-06 14:29:28 -05:00
Robert
999111e5b3 Revert "auth/aws: fix panic in IAM-based login when client config doesn't exist (#23366)" (#23480)
This reverts commit 80e1912adb.
2023-10-03 16:01:40 -05:00
Austin Gebauer
80e1912adb auth/aws: fix panic in IAM-based login when client config doesn't exist (#23366)
* auth/aws: fix panic in IAM-based login when client config doesn't exist

* add changelog

* adds known issue for 1.15.0

* fixes up known issue with workaround

* fix link

* maintain behavior of client config not needing to exist for IAM login

* update changelog
2023-09-30 11:25:56 +09:00
Steven Clark
b0fef53184 Do not attempt to shutdown ACME thread on non-active nodes (#23293) 2023-09-26 16:32:52 -04:00
Steven Clark
dbfaa6f81a Stop processing ACME verifications when active node is stepped down (#23278)
- Do not load existing ACME challenges persisted within storage on non-active nodes. This was the main culprit of the issues, secondary nodes would load existing persisted challenges trying to resolve them but writes would fail leading to the excessive logging.
    - We now handle this by not starting the ACME background thread on non-active nodes, while also checking within the scheduling loop and breaking out. That will force a re-reading of the Closing channel that should have been called by the PKI plugin's Cleanup method.

- If a node is stepped down from being the active node while it is actively processing a verification, we could get into an infinite loop due to an ErrReadOnly error attempting to clean up a challenge entry

- Add a maximum number of retries for errors around attempting to decode,fetch challenge/authorization entries from disk. We use double the number of "normal" max attempts for these types of errors, than we would for normal ACME retry attempts to avoid collision issues. Note that these additional retry attempts are not persisted to disk and will restart on every node start

- Add a 1 second backoff to any disk related error to not immediately spin on disk/io errors for challenges.
2023-09-26 13:59:13 -04:00
vinay-gopalan
8924f9592d Remove SA Credentials from DB Connection Details on Read (#23256) 2023-09-22 10:49:46 -07:00
John-Michael Faircloth
9569b16114 secrets/db: add rotation error path test (#23182)
* secrets/db: add rotation error path test

We add a test to verify that failed rotations can successfully recover
and that they do not occur outside of a rotation window. Additionally,
we remove registering some external plugins in getCluster() that shaves
off about 5 minutes the database package tests.

* remove dead code and add test comment

* revert to original container helper after refactor
2023-09-20 14:07:17 -05:00
Violet Hynes
f943c37a83 VAULT-19237 Add mount_type to secret response (#23047)
* VAULT-19237 Add mount_type to secret response

* VAULT-19237 changelog

* VAULT-19237 make MountType generic

* VAULT-19237 clean up comment

* VAULT-19237 update changelog

* VAULT-19237 update test, remove mounttype from wrapped responses

* VAULT-19237 fix a lot of tests

* VAULT-19237 standby test
2023-09-20 09:28:52 -04:00
John-Michael Faircloth
1e76ad42ef secrets/db: add tests for static role config updates (#23153) 2023-09-19 10:12:09 -05:00
Raymond Ho
018e5675fe VAULT 18227/introduce cap ldap library (#22185) 2023-09-14 10:26:29 -07:00
Steven Clark
293e8b8ac5 Fix enterprise failure of TestCRLIssuerRemoval (#23038)
This fixes the enterprise failure of the test
 ```
  === FAIL: builtin/logical/pki TestCRLIssuerRemoval (0.00s)
     crl_test.go:1456:
         	Error Trace:	/home/runner/actions-runner/_work/vault-enterprise/vault-enterprise/builtin/logical/pki/crl_test.go:1456
         	Error:      	Received unexpected error:
         	            	Global, cross-cluster revocation queue cannot be enabled when auto rebuilding is disabled as the local cluster may not have the certificate entry!
         	Test:       	TestCRLIssuerRemoval
         	Messages:   	failed enabling unified CRLs on enterprise

 ```
2023-09-13 08:11:52 -04:00
Alexander Scheel
e2ff1f1c71 Clean up unused CRL entries when issuer is removed (#23007)
* Clean up unused CRL entries when issuer is removed

When a issuer is removed, the space utilized by its CRL was not freed,
both from the CRL config mapping issuer IDs to CRL IDs and from the
CRL storage entry. We thus implement a two step cleanup, wherein
orphaned CRL IDs are removed from the config and any remaining full
CRL entries are removed from disk.

This relates to a Consul<->Vault interop issue (#22980), wherein Consul
creates a new issuer on every leadership election, causing this config
to grow. Deleting issuers manually does not entirely solve this problem
as the config does not fully reclaim space used in this entry.

Notably, an observation that when deleting issuers, the CRL was rebuilt
on secondary clusters (due to the invalidation not caring about type of
the operation); for consistency and to clean up the unified CRLs, we
also need to run the rebuild on the active primary cluster that deleted
the issuer as well.

This approach does allow cleanup on existing impacted clusters by simply
rebuilding the CRL.

Co-authored-by: Steven Clark <steven.clark@hashicorp.com>
Signed-off-by: Alexander Scheel <alex.scheel@hashicorp.com>

* Add test case on CRL removal

Signed-off-by: Alexander Scheel <alex.scheel@hashicorp.com>

* Add changelog entry

Signed-off-by: Alexander Scheel <alex.scheel@hashicorp.com>

---------

Signed-off-by: Alexander Scheel <alex.scheel@hashicorp.com>
Co-authored-by: Steven Clark <steven.clark@hashicorp.com>
2023-09-12 20:56:47 +00:00
Peter Wilson
ae774b93d3 VAULT-18160: Audit - options and defaults (#22295)
* options for syslog

* fix bug in default value for HMACAccessor

* backend device cleanup

* socket backend options update

* options: prefix removed check, added default file mode

* fix option setting for elision

* fix test for prefix and whitespace
2023-09-11 08:41:29 +00:00
Scott Miller
7d4d8cb708 Reject supplied nonces for non-convergent encryption operations (#22852)
* Ignore nonces when encrypting without convergence or with convergence versions > 1

* Honor nonce use warning in non-FIPS modes

* Revert "Honor nonce use warning in non-FIPS modes"

This reverts commit 2aee3dbdc11c4e333ecb20503539c7993b24ee57.

* Add a test func that removes a nonce when not needed

* err out rather than ignore the nonce

* Alter unit test to cover, also cover convergent version 3

* More unit test work

* Fix test 14

* changelog

* tests not already in a nonce present path

* Update unit test to not assume warning when nonce provided incorrectly

* remove unused test field

* Fix auto-squash events experiments

When #22835 was merged, it was auto-squashed, so the `experiments`
import was removed, but the test still referenced it.

This removes the (now unnecessary) experiment from the test.

* Allow nonces for managed keys, because we have no way of knowing if the backing cipher/mode needs one

---------

Co-authored-by: Christopher Swenson <christopher.swenson@hashicorp.com>
2023-09-08 08:07:33 -05:00
John-Michael Faircloth
16f805419f fix rotation_window bug in error path (#22699) 2023-08-31 15:45:01 -05:00
John-Michael Faircloth
aa05ba6105 adv ttl mgmt: define schedule interface (#22590) 2023-08-28 13:14:38 -07:00
Thomas Schweizer-Bolzonello
958eb96bab Fix typo OSCP -> OCSP (#22586) 2023-08-28 18:39:01 +00:00
Max Bowsher
479519e6df Fix erroneous OpenAPI operation IDs (#22579)
The recent additions to the transit secret engine have created two new
endpoints which both have the incorrect (and duplicate) operation ID of
just `"update"`.

Amend to unique meaningful values.
2023-08-28 09:11:16 -04:00
Milena Zlaticanin
2d0d5c79ed Add the ability to set seconds in cron schedule for testing purposes (#22531)
* add rotation_schedule field to db backend

* add cron schedule field

* use priority queue with scheduled rotation types

* allow marshalling of cron schedule type

* return warning on use of mutually exclusive fields

* handle mutual exclusion of rotation fields (#22306)

* handle mutual exclusion of rotation fields

* fix import

* adv ttl mgmt: add rotation_window field (#22303)

* adv ttl mgmt: add rotation_window field

* do some rotation_window validation and add unit tests

* adv ttl mgmt: Ensure initialization sets appropriate rotation schedule (#22341)

* general cleanup and refactor rotation type checks

* make NextRotationTime account for the rotation type

* add comments

* add unit tests to handle mutual exclusion (#22352)

* add unit tests to handle mutual exclusion

* revert rotation_test.go and add missing test case to path_roles_test.go

* adv ttl mgmt: add tests for init queue (#22376)

* Vault 18908/handle manual rotation (#22389)

* support manual rotation for schedule based roles

* update description and naming

* adv ttl mgmt: consider rotation window (#22448)

* consider rotation window

ensure rotations only occur within a rotation window for schedule-based
rotations

* use helper method to set priority in rotateCredential

* fix bug with priority check

* remove test for now

* add and remove comments

* add unit tests for manual rotation (#22453)

* adv ttl mgmt: add tests for rotation_window

* adv ttl mgmt: refactor window tests (#22472)

* Handle GET static-creds endpoint (#22476)

* update read static-creds endpoint to include correct resp data

* return rotation_window if set

* update

* add changelog

* add unit test for static-creds read endpoint (#22505)

* Add the ability to set seconds in cron schedule for testing purposes

* update test so we don't use global var

* update with suggestions

---------

Co-authored-by: JM Faircloth <jmfaircloth@hashicorp.com>
Co-authored-by: John-Michael Faircloth <fairclothjm@users.noreply.github.com>
2023-08-25 09:42:15 -07:00