Commit Graph

773 Commits

Author SHA1 Message Date
AJ Heller 1a8b22f2de [build] Restrict visibility for creating core credentials types. (#36216)
Closes #36216

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36216 from drfloob:conceal-core-cred-creation a44a299273
PiperOrigin-RevId: 625425746
2024-04-17 01:21:29 +00:00
Craig Tiller b0cf42d86e [clang-format] Remove requirement that port_platform.h is at the top (#36281)
Closes #36281

PiperOrigin-RevId: 623176865
2024-04-09 08:58:34 -07:00
Craig Tiller 8b8f43aecf [metadata] Remove arena from `grpc_metadata_batch` constructor (#36118)
Internally, use `std::vector` instead of `ChunkedVector` to hold extra metadatum.

I'm not totally convinced this is the right move, so it's going to be a try it and monitor for a month or so thing... I might roll back if performance is actually affected (but I think we'll see some wins and losses and overall about a wash).

Closes #36118

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36118 from ctiller:YUPYUPYUP 68e0acd0a2
PiperOrigin-RevId: 620902195
2024-04-01 11:23:54 -07:00
Tanvi Jagtap 8013ffe965 [grpc][Gpr_To_Absl_Logging] Fixing minor typo
PiperOrigin-RevId: 619432986
2024-03-27 00:00:11 -07:00
Tanvi Jagtap e39bd50716 [grpc] Redacting unknown metadata types in debug logs. (#36006)
Redacting unknown metadata types in debug logs.

<!--

If you know who should review your pull request, please assign it to that
person, otherwise the pull request would get assigned randomly.

If your pull request is for a specific language, please add the appropriate
lang label.

-->

Closes #36006

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36006 from tanvi-jagtap:tjagtap_redact_01 94c5738bfe
PiperOrigin-RevId: 611334483
2024-02-28 21:18:41 -08:00
Gregory Cooke d6089c336c [Security - CrlProvider] Add AKID to CertificateInfo (#35931)
This PR adds the Authority Key Identifier to CertificateInfo. This value _can be_ important in finding the right CRLs to use if there are Issuer name overlaps or a more complicated CA setup with multiple signing keys.

We should observe no behavior change in our `CrlProvider` implementations, this is just adding an important field for users who implement it themselves.

Closes #35931

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/35931 from gtcooke94:AkidCheck dd048a53b6
PiperOrigin-RevId: 611143198
2024-02-28 10:19:05 -08:00
Gregory Cooke a1b7e1e523 [Security] Crl helpers (#35963)
Re-applies after the revert
Fixes the Openssl 1.0.2 portability errors

Closes #35963

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/35963 from gtcooke94:CrlHelpers 9cfb401a47
PiperOrigin-RevId: 610503595
2024-02-26 13:12:36 -08:00
Matthew Stevenson 51bccbdcf9 [ssl] Support Windows system roots. (#34874)
This PR is copied from #34276, since I did not have permissions to add commits to it. That PR has been verified to work (see the top-level description). This PR just makes the gRPC tests pass (e.g. adding includes, clang formatting).

Closes #34874

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/34874 from matthewstevenson88:pull_34276 d5fb73e5b2
PiperOrigin-RevId: 609107146
2024-02-21 13:40:46 -08:00
AJ Heller a82a28cde4 Revert "[Security - CrlProvider] Use a better mechanism for Crl Looku… (#35962)
…p and add some verification helpers (#35641)"

This reverts commit 310770d61d.

It breaks all portability tests.

```
[==========] Running 1 test from 1 test suite.
[----------] Global test environment set-up.
[----------] 1 test from CrlUtils
[ RUN      ] CrlUtils.HasCrlSignBitExists
/[var/local/git/grpc/test/core/tsi/ssl_transport_security_utils_test.cc:566](https://cs.corp.google.com/piper///depot/google3/var/local/git/grpc/test/core/tsi/ssl_transport_security_utils_test.cc?l=566): Failure
Value of: HasCrlSignBit(root_ca_)
  Actual: false
Expected: true

[  FAILED  ] CrlUtils.HasCrlSignBitExists (0 ms)
[----------] 1 test from CrlUtils (0 ms total)

[----------] Global test environment tear-down
[==========] 1 test from 1 test suite ran. (0 ms total)
[  PASSED  ] 0 tests.
[  FAILED  ] 1 test, listed below:
[  FAILED  ] CrlUtils.HasCrlSignBitExists
```

Closes #35962

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/35962 from drfloob:revert-310770d61d3b25d358d877a074bebf6ae85549d0 e6a2f03309
PiperOrigin-RevId: 609075479
2024-02-21 12:00:50 -08:00
Gregory Cooke 310770d61d [Security - CrlProvider] Use a better mechanism for Crl Lookup and add some verification helpers (#35641)
This PR does 2 distinct things, I can unbundle them if desired

1) Add functions in `ssl_transport_security_utils` and associated tests that will eventually be used for additional Crl validation (the logic of actually doing this will be in a future PR), so other than the tests these fns are currently unused.

2) Remove the use of `X509_NAME_oneline` - it is not a guaranteed stable way to get the issuer name for lookups. Instead, use the DER encoding via `i2d_X509_NAME` - the results in a non-human readable string that is stable for lookup, and necessitated some change to the CrlProvider test code that previously used a human readable string for this value.

Neither should result in behavior changes.

Closes #35641

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/35641 from gtcooke94:CrlRefactor 2b6f63717c
PiperOrigin-RevId: 607701254
2024-02-16 08:45:59 -08:00
Mark D. Roth 17d9e20ff1 [slice] use absl base64 APIs instead of slice base64 APIs (#35851)
Closes #35851

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/35851 from markdroth:base64 6caf83d3da
PiperOrigin-RevId: 606759013
2024-02-13 15:05:50 -08:00
Mark D. Roth 41606054c2 [load_file] remove grpc_load_file() in favor of grpc_core::LoadFile() (#35857)
Closes #35857

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/35857 from markdroth:highlander 7b7d95aaa9
PiperOrigin-RevId: 605742734
2024-02-09 15:16:24 -08:00
AJ Heller 521b2ea17c [EventEngine] Make oauth2 test utils work with EventEngine clients (#35866)
The Oauth2 credentials currently rely on pollsets and polling entities, partially because grpc_core::HttpRequest relies on them as well. This is a temporary solution to get both iomgr and EventEngine clients to pass the oauth2 interop tests.

Tested with the client experiment on and off.

Closes #35866

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/35866 from drfloob:oauth2_utils_work_with_ee_hack 91eea0c196
PiperOrigin-RevId: 605433817
2024-02-08 14:49:43 -08:00
Esun Kim 1a20f21b6b Fixed multi-line comments warning (#35351)
Adding more stuff on top of https://github.com/grpc/grpc/pull/35127

Closes #35351

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/35351 from veblush:fix-line 1b25e5df49
PiperOrigin-RevId: 600810979
2024-01-23 09:20:33 -08:00
Mark D. Roth c7101d0867 [xDS] move CDS and EDS watchers into xds resolver (#35011)
Implements gRFC A74 (https://github.com/grpc/proposal/pull/404).

Closes #35011

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/35011 from markdroth:xds_watchers_in_xds_resolver a39f71f37f
PiperOrigin-RevId: 595134549
2024-01-02 09:20:06 -08:00
Matthew Stevenson af36847fb5 [alpn] Remove grpc-exp experimental ALPN protocol. (#34876)
This fixes #21619. This experimental ALPN protocol has already been removed from the other gRPC stacks.

Closes #34876

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/34876 from matthewstevenson88:remove-grpc-exp 1cb9d084ea
PiperOrigin-RevId: 592080195
2023-12-18 19:52:55 -08:00
Luwei Ge dd12460018 [tls] Add set min/max TLS version APIs to TLS credentials APIs. (#34861)
Address #28382. This is a recreation of #31368 except e2e tests are not handled here (yet).

Closes #34861

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/34861 from rockspore:tls_version f9a1215ac1
PiperOrigin-RevId: 589847110
2023-12-11 09:27:44 -08:00
aeitzman 79c9a67dee [core/security] Adding metrics header to sts request for external account credentials (#34661)
Closes #34661

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/34661 from aeitzman:metrics 9f53992ed4
PiperOrigin-RevId: 585796526
2023-11-27 16:48:36 -08:00
Gregory Cooke 0d4e1ef5df
[Security - Revocation] Crl Directory Watcher Implementation (#34749)
This adds the directory reloader implementation of the CrlProvider. This
will periodically reload CRL files in a directory per [gRFC
A69](https://github.com/grpc/proposal/pull/382)

Included in this is the following:
* A public API to create the `DirectoryReloaderCrlProvider`
* A basic directory interface in gprpp and platform specific impls for
getting the list of files in a directory (unfortunately prior C++17,
there is no std::filesystem, so we have to have platform specific impls)
* The implementation of `DirectoryReloaderCrlProvider` takes an
event_engine and a directory interface. This allows us to test using the
fuzzing event engine for time mocking, and to implement a test directory
interface so we avoid having to make temporary directories and files in
the tests. This is notably not in `include`, and the
`CreateDirectoryReloaderCrlProvider` is the only way to construct one
from the public API, so we don't expose the event engine and directory
details to the user.

---------

Co-authored-by: gtcooke94 <gtcooke94@users.noreply.github.com>
2023-11-03 20:48:05 +00:00
Gregory Cooke 0b1e381d56
[Security] Fix bug for layered composite creds (#34860)
Address https://github.com/grpc/grpc/issues/12554

The API for `duplicate_without_call_credentials` says 
```
// Creates a version of the channel credentials without any attached call
// credentials. This can be used in order to open a channel to a non-trusted
// gRPC load balancer.
```

As the impl stands right now, because of that description, in the case
of layered composite creds, I think the right behavior would be to call
down until you get the base cred with no call cred.

In discussing with the team, we do wonder if the use-case of layered
composite creds is really something that should be a feature, or if we
should be checking during the creation of composite creds to make sure
we aren't layering composite creds? @markdroth can you give your
thoughts?
2023-11-03 10:34:18 -04:00
Gregory Cooke 9969d820b5
[TLS - Revocation] Crl Provider (#34715)
This reverts commit 7af5efcfd3.
2023-10-19 11:33:41 -07:00
apolcyn 7af5efcfd3
Revert "[TLS - Revocation] Crl Provider (#33786)" (#34713)
This reverts commit 0f0396ae92.
2023-10-17 13:53:36 -07:00
Gregory Cooke 0f0396ae92
[TLS - Revocation] Crl Provider (#33786)
The basic APIs for the CRL Reloading features.
This adds external types to represent CRL Providers, CRLs, and
CertificateInfo.
Internally we will use `CrlImpl` - this layer is needed to hide OpenSSL
details from the user.

GRFC - https://github.com/grpc/proposal/pull/382

Things Done
* Add external API for `CrlProvider`, `Crl`, `CertInfo` (`CertInfo` is
used during CRL lookup rather than passing the entire certificate).
* Add code paths in `ssl_transport_security` to utilize CRL providers
* Add `StaticCrlProvider`
* Refactor `crl_ssl_transport_security_test.cc` so it is more extensible
and can be used with providers
2023-10-17 13:03:52 -04:00
Craig Tiller 0814055337
[fuzzers] Expand client_fuzzer, server_fuzzer (#34596)
Allow multiple writes, and allow those writes to know about http2
(leverages the new framing layer for chttp2 recently written)
2023-10-05 15:22:39 -07:00
jrandolf 3489b6304e
[OpenSSL] Support for OpenSSL 3 (#31256)
Update from gtcooke94:
This PR adds support to build gRPC and it's tests with OpenSSL3. There were some
hiccups with tests as the tests with openssl haven't been built or exercised in a
few months, so they needed some work to fix.

Right now I expect all test files to pass except the following:
- h2_ssl_cert_test
- ssl_transport_security_utils_test

I confirmed locally that these tests fail with OpenSSL 1.1.1 as well,
thus we are at least not introducing regressions. Thus, I've added compiler directives around these tests so they only build when using BoringSSL.

---------

Co-authored-by: Gregory Cooke <gregorycooke@google.com>
Co-authored-by: Esun Kim <veblush@google.com>
2023-08-21 17:42:32 -04:00
Mario Jones Vimal a934848de5
[core/security] Add Custom Token Lifetime - Service Acc Impersonation (#33351)
Adds access token lifetime configuration for workload identity
federation with service account impersonation for both explicit and
implicit flows.

Changes: 
1. Adds a new member "service_account_impersonation" to the
ExternalAccountCredentials class. "token_lifetime_seconds" is a member
of "service_account_impersonation".
2. Adds validation checks, like token_lifetime_seconds should be between
the minimum and maximum accepted value, during the creation of an
ExternalAccountCredentials object.
3. Appends "lifetime" to the body of the service account impersonation
request.

Tests:
1. Modifies a test to check if the default value is passed when
"service_account_impersonation" is empty.
2. Adds tests to check if the token_lifetime_seconds value is propagated
to the request body.
3. Adds tests to verify that an error is thrown when
token_lifetime_seconds is invalid.
2023-07-13 11:42:26 -04:00
Matthew Stevenson 278978d6f0
[tls] Remove use of SSL_CTX_set_client_CA_list for TLS server credentials. (#33558)
This PR does the following: for the TLS server credentials, stops
calling `SSL_CTX_set_client_CA_list` by default in
`ssl_transport_security.cc`, and gives users a knob to re-enable calling
this API.

## What does the `SSL_CTX_set_client_CA_list` API do?

When this API is called, a gRPC TLS server sends the following data in
the ServerHello: for each certificate in the server's trust bundle, the
CA name in the certificate.

This API does not change the set of certificates trusted by the server
in any way. Rather, it is just providing a hint to the client about what
client certificate should be sent to the server.

## Why are we removing the use of `SSL_CTX_set_client_CA_list` by
default for the TLS server credentials?

Removing the use of this API by default has 2 benefits:
1. Calling this API makes gRPC TLS unusable for servers with a
sufficiently large trust bundle. Indeed, if the server trust bundle is
too large, then the server will always fail to build the ServerHello.
2. Calling this API is introducing a huge amount of overhead (1000s of
bytes) to each ServerHello, so removing this feature will improve
connection establishment latency for all users of the TLS server
credentials.
2023-06-29 09:48:15 -07:00
Mark D. Roth 1b31c6e0ba
[xDS] support "tls" channel creds in bootstrap file (#33234)
Implements [gRFC
A65](https://github.com/grpc/proposal/blob/master/A65-xds-mtls-creds-in-bootstrap.md).

Fixes #32977.
2023-06-16 08:07:58 -07:00
Mark D. Roth 52d687ad42
[xDS] second attempt: clean up cert provider factory and registry APIs (#33249)
Original was #33226, reverted in #33248.
2023-05-25 12:59:21 -07:00
Craig Tiller 9faa39d88b
Revert "[xDS] clean up cert provider factory and registry APIs" (#33248)
Reverts grpc/grpc#33226

(looks to be creating some import problems)
2023-05-25 09:56:01 -07:00
Mark D. Roth eb2b1edd1c
[xDS] clean up cert provider factory and registry APIs (#33226)
- switch to json_object_loader for config parsing
- use `absl::string_view` instead of `const char*` for cert provider
names
- change cert provider registry to use a map instead of a vector
- remove unused mesh_ca cert provider factory
2023-05-24 15:38:39 -07:00
Luwei Ge de9d398e8f
[Audit Logging] End2end test for audit logging in authorization policy (#33196)
I generated a new client key and cert where a Spiffe ID is added as the
URI SAN. As such, we are able to test the audit log contains the
principal correctly.

Update: I switched to use the test logger to verify the log content and
removed stdout logger here because one the failure of [RBE Windows Debug
C/C++](https://source.cloud.google.com/results/invocations/c3187f41-bb1f-44b3-b2b1-23f38e47386d).

Update again: Refactored the test logger in a util such that the authz
engine test also uses the same logger. Subsequently, xDS e2e test will
also use it.

---------

Co-authored-by: rockspore <rockspore@users.noreply.github.com>
2023-05-24 14:09:32 -07:00
Mark D. Roth ec31abdacf
[xDS] support StringMatch for header matching in RouteConfig (#32993)
Implements [gRFC
A63](https://github.com/grpc/proposal/blob/master/A63-xds-string-matcher-in-header-matching.md).

---------

Co-authored-by: markdroth <markdroth@users.noreply.github.com>
2023-05-19 09:16:06 -07:00
Luwei Ge 0d70c632fb
[Audit Logging] Second attempt: rbac service config parsing with audit logging (#33183)
This is basically the same as #33145 except that the ctor `Rules()`
cannot be default but have to explicitly set a default audit condition.
2023-05-18 14:27:26 -07:00
Eugene Ostroukhov 922b18f71b
Revert "[Audit Logging] Audit logging config translation by rbac service config parser" (#33178)
Reverts grpc/grpc#33145

It causes internal breakages.
2023-05-18 10:58:16 -07:00
Luwei Ge f60d0c7247
[Audit Logging] Audit logging config translation by rbac service config parser (#33145)
This translates the service config from HTTP RBAC filter into the rbac
policy, which is used to construct authorization engines.
2023-05-17 15:15:30 -07:00
Luwei Ge 6df358cf6a
[Audit Logging] Stdout logger implementation (#33026)
The logger uses `absl::FPrintF` to write to stdout. After reading a
number of sources online, I got the impression that `std::fwrite` which
is used by `absl::FPrintF` is atomic so there is no locking required
here.

---------

Co-authored-by: rockspore <rockspore@users.noreply.github.com>
2023-05-16 10:02:22 -07:00
Esun Kim 37e9903ecb
[Build] Fix json error (#33051)
To fix this error

```
test/core/security/grpc_authorization_engine_test.cc:88:32: error: unknown type name 'Json'; did you mean 'experimental::Json'?
  ParseAuditLoggerConfig(const Json&) override {
                               ^~~~
                               experimental::Json
```
2023-05-09 10:06:09 -07:00
Mark D. Roth 1432fe4e4c
[JSON] make API public but experimental (#32987)
This makes the JSON API visible as part of the C-core API, but in the
`experimental` namespace. It will be used as part of various
experimental APIs that we will be introducing in the near future, such
as the audit logging API.
2023-05-09 08:05:24 -07:00
Luwei Ge abc82b9e19
[Audit Logging] Audit logging support in authorization engines. (#32995)
1. `GrpcAuthorizationEngine` creates the logger from the given config in
its ctor.
2. `Evaluate()` invokes audit logging when needed.

---------

Co-authored-by: rockspore <rockspore@users.noreply.github.com>
2023-05-03 14:07:39 -07:00
Luwei Ge 3541ef5d69
[Audit Logging] Authz policy support for audit logging (#32944)
Add audit condition and audit logger config into `grpc_core::Rbac`.
Support translation of audit logging options from authz policy to it.

Audit logging options in authz policy looks like:
```json
{
  "audit_logging_options": {
    "audit_condition": "ON_DENY",
    "audit_loggers": [
      {
        "name": "logger",
        "config": {},
        "is_optional": false
      }
    ]
  }
}
```
which is consistent with what's in the xDS RBAC proto but a little
flattened.

---------

Co-authored-by: rockspore <rockspore@users.noreply.github.com>
2023-05-02 15:51:46 -07:00
Mark D. Roth 844e740183
[JSON] Replace ctors with factory methods (#32834) 2023-05-02 09:22:42 -07:00
Luwei Ge dcfc5d6904
[Audit Logging] Logger and factory APIs in C-Core and C++. (#32750)
Audit logging APIs for both built-in loggers and third-party logger
implementations.

C++ uses using decls referring to C-Core APIs.

---------

Co-authored-by: rockspore <rockspore@users.noreply.github.com>
2023-04-26 06:44:14 -07:00
Mark D. Roth 36d2716d52
[JSON] move Parse() and Dump() methods out of JSON object (#32742)
More prep for making this a public API.
2023-03-30 13:30:54 -07:00
Mark D. Roth 656e5f283b
[JSON] use updated style for enum values (#32741)
More preparation for making this a public API.
2023-03-30 09:39:07 -07:00
Mark D. Roth 3a8f499645
[JSON] Rename some accessor methods for consistency (#32740)
A bit of cleanup in preparation for making this a public API.
2023-03-30 07:13:15 -07:00
Craig Tiller 175ccc3a90
Reland global config changes (#32661)
<!--

If you know who should review your pull request, please assign it to
that
person, otherwise the pull request would get assigned randomly.

If your pull request is for a specific language, please add the
appropriate
lang label.

-->

---------

Co-authored-by: ctiller <ctiller@users.noreply.github.com>
2023-03-27 18:55:24 -07:00
Jin c3bd5e9a1e
fix: gRPC: Remove AWS URL validation (#32674)
As of adding support in future for TPC support. We removed all url
validations from Credentials.
AWS url validation doesn't make sense here either.
2023-03-24 16:22:22 -07:00
Carl Lundin 87818f60fe
AWSCredentials: fix interaction with metadata server (#32532)
* No need to call metadata server if environment variables are set.
* AWS_SESSION_TOKEN is optional.
2023-03-22 15:05:23 -07:00
Jan Tattermusch 0c1797cd9f
Revert "[config] Move global config alongside core configuration" (#32659)
Reverts grpc/grpc#30788

(it breaks grpc_objc_bazel_test (see
https://github.com/grpc/grpc/pull/30788#issuecomment-1476372187) and
also seems to be breaking some other internal stuff).
2023-03-20 08:22:29 -07:00