Skip to content

Commit 9d13f1b

Browse files
author
Katyal
committed
Add back in the verification of the certs by open SSL library
Prior to this change, We had removed the validation of the signed message during https://code.amazon.com/reviews/CR-1228125/revisions/1#/diff. This change will address the security concern the AWS Security team had about our validation.https://tt.amazon.com/E035418734 has more details. cr https://code.amazon.com/reviews/CR-2042604
1 parent 5d093ab commit 9d13f1b

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

lib/instance_agent/plugins/codedeploy/deployment_specification.rb

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,17 @@ def self.parse(envelope)
106106
case envelope.format
107107
when "PKCS7/JSON"
108108
pkcs7 = OpenSSL::PKCS7.new(envelope.payload)
109-
pkcs7.verify([], @cert_store, nil, OpenSSL::PKCS7::NOVERIFY)
110-
# NOTE: the pkcs7.data field is only populated AFTER pkcs7.verify() is called!
109+
110+
# The PKCS7_NOCHAIN flag tells OpenSSL to ignore any PKCS7 CA chain that might be attached
111+
# to the message directly and use the certificates from provided one only for validating the.
112+
# signer's certificate.
113+
#
114+
# However, it will allow use the PKCS7 signer certificate provided to validate the signature.
115+
#
116+
# http://www.openssl.org/docs/crypto/PKCS7_verify.html#VERIFY_PROCESS
117+
#
118+
# The ruby wrapper returns true if OpenSSL returns 1
119+
raise "Validation of PKCS7 signed message failed" unless pkcs7.verify([], @cert_store, nil, OpenSSL::PKCS7::NOCHAIN)
111120
parse_deployment_spec_data(pkcs7.data)
112121
when "TEXT/JSON"
113122
raise "Unsupported DeploymentSpecification format: #{envelope.format}" unless AWS::CodeDeploy::Local::Deployer.running_as_developer_utility?

0 commit comments

Comments
 (0)