Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BFD-3723: Determine SAMHSA authorization based on certificate identity #2486

Open
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

aschey-forpeople
Copy link
Contributor

@aschey-forpeople aschey-forpeople commented Nov 8, 2024

JIRA Ticket:
BFD-3723

What Does This PR Do?

This change reduces the likelihood of a SAMHSA incident by automatically disallowing any client from seeing SAMHSA data unless they use a certificate that is explicitly allowed. We do this by dynamically loading in the serial numbers for each allowed certificate at startup. The allowed certificates are determined by a new configuration parameter samhsa_allowed_certificate_aliases_json. The values in that parameter directly match the names under client_certificates/*, which are used to populate the trust store on deployment. Serial numbers are not globally unique, but they are unique per CA, which should be sufficient enough to verify identity for our purposes.

On each request, we extract the serial number from the provided client certificate and compare it with the list of allowed certificates that we generated on startup. The excludeSAMHSA parameter is still honored for any clients that are allowed to see SAMHSA info.

I've added the list of certificates that should have SAMHSA access and created a new certificate per environment for internal testing.

What Should Reviewers Watch For?

If you're reviewing this PR, please check for these things in particular:

  • Verify that the list of allowed certificates is correct

What Security Implications Does This PR Have?

Please indicate if this PR does any of the following:

  • Adds any new software dependencies

  • Modifies any security controls

  • Adds new transmission or storage of data

  • Any other changes that could possibly affect security?

  • I have considered the above security implications as it relates to this PR. (If one or more of the above apply, it cannot be merged without the ISSO or team security engineer's (@sb-benohe) approval.)

This change does affect security controls.

Validation

Have you fully verified and tested these changes? Is the acceptance criteria met? Please provide reproducible testing instructions, code snippets, or screenshots as applicable.

  • New tests added
  • Deployed to an ephemeral environment and verified the new certificates are being validated as expected

fi

# Skip binary formats
case "$extension" in
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shellcheck was blowing up when trying to parse the certificate formats

@@ -160,12 +160,13 @@ if lsof -Pi :4566 -sTCP:LISTEN -t >/dev/null ; then
export AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY
export AWS_SECRET_ACCESS_KEY=$AWS_SECRET_KEY
SSM_PARAMETER_PATH=/bfd-server
export CONFIG_SETTINGS_JSON=$(cat <<EOF
CONFIG_SETTINGS_JSON=$(cat <<EOF
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shellcheck wanted the export on a separate line

# If debug_suspend is y the pipeline app will wait for a debugger to connect before doing any work.
if [[ $debug_enabled = "true" ]] ; then
ARGS="$ARGS -agentlib:jdwp=transport=dt_socket,server=y,suspend=${debug_suspend},address=*:5005"
ARGS="$ARGS -agentlib:jdwp=transport=dt_socket,server=y,suspend=${debug_suspend},address=*:${debug_port}"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The debug_port variable already existed, but wasn't used, so shellcheck was complaining. Figure we might as well use it since it already exists.

@@ -294,7 +296,7 @@ if [[ x$kubernetes = xtrue ]] ; then
elif [[ x$image_tag = x ]] ; then
echo running application directly
export CLASSPATH="$classpath"
exec $java $properties $ARGS $mainClass
exec $java $ARGS $mainClass
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$properties wasn't being set anywhere so it didn't do anything.

/***
* test.
*/
public class ClientCertificateUtils {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of this was moved here from RequestResponseMdcFilter so it can be reused.

@aschey-forpeople aschey-forpeople marked this pull request as ready for review November 15, 2024 01:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants