Skip to content

Commit

Permalink
Jenkins CLI CVE mitigation (#388)
Browse files Browse the repository at this point in the history
* jenkins cve mitigation

Signed-off-by: Jeff Lu <chunglu@amazon.com>

* using curl to replace wget

Signed-off-by: Jeff Lu <chunglu@amazon.com>

* using the commit Id instead of the main branch

Signed-off-by: Jeff Lu <chunglu@amazon.com>

---------

Signed-off-by: Jeff Lu <chunglu@amazon.com>
  • Loading branch information
jordarlu authored Feb 21, 2024
1 parent f2abb8c commit fa7290b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions lib/compute/jenkins-main-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,11 @@ export class JenkinsMainNode {
+ ' instance_id=`curl -f -H "X-aws-ec2-metadata-token: $TOKEN" http://169.254.169.254/latest/meta-data/instance-id` && echo $ami_id &&'
+ ` aws ec2 --region ${stackRegion} modify-instance-metadata-options --instance-id $instance_id --http-put-response-hop-limit 2`),

// Jenkins CVE https://www.jenkins.io/security/advisory/2024-01-24/ mitigation
InitCommand.shellCommand('mkdir -p /var/lib/jenkins/init.groovy.d'),
// eslint-disable-next-line max-len
InitCommand.shellCommand('sudo curl -SL https://raw.githubusercontent.com/jenkinsci-cert/SECURITY-3314-3315/1363970ecc33a6b94620f2167d4a301fcf46bd36/disable-cli.groovy -o /var/lib/jenkins/init.groovy.d/disable-cli.groovy'),

// Configuration to proxy jenkins on :8080 -> :80
InitFile.fromString('/etc/httpd/conf.d/jenkins.conf',
httpConfigProps.useSsl
Expand Down
2 changes: 1 addition & 1 deletion test/compute/jenkins-main-node.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe('JenkinsMainNode Config Elements', () => {

// THEN
test('Config elements expected counts', async () => {
expect(configElements.filter((e) => e.elementType === 'COMMAND')).toHaveLength(20);
expect(configElements.filter((e) => e.elementType === 'COMMAND')).toHaveLength(22);
expect(configElements.filter((e) => e.elementType === 'PACKAGE')).toHaveLength(9);
expect(configElements.filter((e) => e.elementType === 'FILE')).toHaveLength(4);
});
Expand Down

0 comments on commit fa7290b

Please sign in to comment.