0
0
Jenkinsdevops~20 mins

CSRF protection in Jenkins - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
CSRF Protection Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
What is the purpose of CSRF protection in Jenkins?

CSRF protection helps Jenkins prevent a specific type of attack. What does it protect against?

AIt encrypts all Jenkins data to prevent data theft.
BIt prevents unauthorized commands from being executed by tricking a logged-in user.
CIt blocks all external IP addresses from accessing Jenkins.
DIt automatically updates Jenkins plugins to the latest version.
Attempts:
2 left
💡 Hint

Think about attacks that use a logged-in user's browser without their knowledge.

Configuration
intermediate
1:30remaining
How to enable CSRF protection in Jenkins?

Which Jenkins configuration step correctly enables CSRF protection?

AAdd a firewall rule blocking all POST requests to Jenkins.
BInstall the CSRF Protection plugin from the Plugin Manager.
CGo to Manage Jenkins > Configure Global Security > Check 'Prevent Cross Site Request Forgery exploits'.
DDisable anonymous access in Jenkins settings.
Attempts:
2 left
💡 Hint

Look for a checkbox in the security settings related to CSRF.

💻 Command Output
advanced
1:30remaining
What is the output when CSRF protection blocks a request?

When Jenkins blocks a request due to CSRF protection, what HTTP status code does it return?

A403 Forbidden
B200 OK
C500 Internal Server Error
D404 Not Found
Attempts:
2 left
💡 Hint

It is a status code that means access is denied.

Troubleshoot
advanced
2:00remaining
Why does a Jenkins API POST request fail with CSRF protection enabled?

You send a POST request to Jenkins API but it fails with 403 error after enabling CSRF protection. What is the most likely cause?

AThe Jenkins server is down.
BThe user does not have admin privileges.
CThe API endpoint URL is incorrect.
DThe request is missing the Jenkins-Crumb header with a valid token.
Attempts:
2 left
💡 Hint

CSRF protection requires a special token in requests.

Best Practice
expert
2:30remaining
What is the recommended best practice for using CSRF protection with Jenkins scripted pipelines?

In Jenkins scripted pipelines, what is the best way to handle CSRF protection tokens when making HTTP POST requests to Jenkins itself?

AUse the 'withCredentials' step to securely fetch and include the Jenkins-Crumb token in headers.
BDisable CSRF protection temporarily during pipeline execution.
CIgnore CSRF tokens because pipelines run inside Jenkins and are trusted.
DManually hardcode a static CSRF token in the pipeline script.
Attempts:
2 left
💡 Hint

Think about securely handling secrets and tokens in Jenkins pipelines.