Issue Summary
This is reproducible on Data Center: ![]()
BAM-21709 introduced a logic to detect the Bamboo Server URL during the Agent bootstrap, which allowed redirected Bamboo server URLs to work when Artifacts would be uploaded back to the Server.
The new logic has an issue related to the Content-Encoding type responses used by some Load Balancers (E.g. Netscaler) where in some circumstances like HTTP Compressed content, the Bamboo Agent fails to detect the Bamboo URL and reports a Null Point Exception.
Steps to Reproduce
- Have Bamboo running behind a Load Balancer or Reverse Proxy
- Enable HTTP compression (gzip) on the Load Balancer or Reverse Proxy
- Try to connect the Agent to Bamboo
It is also possible to reproduce this issue without a proper Load Balancer / Reverse Proxy in case Bamboo's Tomcat is configured to have forced HTTP compression with a compression="force" property set on Bamboo's connector on <bamboo-install>/conf/server.xml
From Apache 2.5.49 (and backported versions) due to CVE-2024-24795, there's a chance that the Reverse Proxy may strip important headers such as Content-Lenght and cause a similar issue as the Bamboo Agent can't validate the response correctly without such headers. For that please add the following property to your Apache HTTPd service and restart it.
SetEnv ap_trust_cgilike_cl 1
Expected Results
The Agent should connect to the server normally.
Actual Results
The Agent fails to start and reports the following error:
STATUS | wrapper | 2023/08/18 12:19:10 | --> Wrapper Started as Console STATUS | wrapper | 2023/08/18 12:19:10 | Java Service Wrapper Standard Edition 64-bit 3.5.51 STATUS | wrapper | 2023/08/18 12:19:10 | Copyright (C) 1999-2022 Tanuki Software, Ltd. All Rights Reserved. STATUS | wrapper | 2023/08/18 12:19:10 | http://wrapper.tanukisoftware.com STATUS | wrapper | 2023/08/18 12:19:10 | Licensed to Atlassian Pty Ltd for Bamboo Remote Agent STATUS | wrapper | 2023/08/18 12:19:10 | STATUS | wrapper | 2023/08/18 12:19:10 | Launching a JVM... INFO | jvm 1 | 2023/08/18 12:19:11 | WrapperManager: Initializing... INFO | jvm 1 | 2023/08/18 12:19:11 | 2023-08-18 12:19:11,623 INFO [WrapperSimpleAppMain] [RemoteAgentBootstrap] Starting Agent Bootstrap using Java 11.0.20 from Red Hat, Inc.. Default charset: UTF-8, file name encoding: UTF-8 INFO | jvm 1 | 2023/08/18 12:19:12 | WrapperSimpleApp: INFO | jvm 1 | 2023/08/18 12:19:12 | WrapperSimpleApp Error: Encountered an error running main: INFO | jvm 1 | 2023/08/18 12:19:12 | WrapperSimpleApp Error: java.lang.reflect.InvocationTargetException INFO | jvm 1 | 2023/08/18 12:19:12 | WrapperSimpleApp Error: at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) INFO | jvm 1 | 2023/08/18 12:19:12 | WrapperSimpleApp Error: at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) INFO | jvm 1 | 2023/08/18 12:19:12 | WrapperSimpleApp Error: at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) INFO | jvm 1 | 2023/08/18 12:19:12 | WrapperSimpleApp Error: at java.base/java.lang.reflect.Method.invoke(Method.java:566) INFO | jvm 1 | 2023/08/18 12:19:12 | WrapperSimpleApp Error: at com.atlassian.bamboo.agent.bootstrap.AgentBootstrap.main(AgentBootstrap.java:21) INFO | jvm 1 | 2023/08/18 12:19:12 | WrapperSimpleApp Error: at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) INFO | jvm 1 | 2023/08/18 12:19:12 | WrapperSimpleApp Error: at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) INFO | jvm 1 | 2023/08/18 12:19:12 | WrapperSimpleApp Error: at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) INFO | jvm 1 | 2023/08/18 12:19:12 | WrapperSimpleApp Error: at java.base/java.lang.reflect.Method.invoke(Method.java:566) INFO | jvm 1 | 2023/08/18 12:19:12 | WrapperSimpleApp Error: at org.tanukisoftware.wrapper.WrapperSimpleApp.run(WrapperSimpleApp.java:349) INFO | jvm 1 | 2023/08/18 12:19:12 | WrapperSimpleApp Error: at java.base/java.lang.Thread.run(Thread.java:829) INFO | jvm 1 | 2023/08/18 12:19:12 | WrapperSimpleApp Error: Caused by: java.lang.NullPointerException INFO | jvm 1 | 2023/08/18 12:19:12 | WrapperSimpleApp Error: at com.atlassian.bamboo.agent.bootstrap.RemoteAgentBootstrap.getFinalUrlWithRedirects(RemoteAgentBootstrap.java:277) INFO | jvm 1 | 2023/08/18 12:19:12 | WrapperSimpleApp Error: at com.atlassian.bamboo.agent.bootstrap.RemoteAgentBootstrap.getBambooUrl(RemoteAgentBootstrap.java:312) INFO | jvm 1 | 2023/08/18 12:19:12 | WrapperSimpleApp Error: at com.atlassian.bamboo.agent.bootstrap.RemoteAgentBootstrap.main(RemoteAgentBootstrap.java:66) INFO | jvm 1 | 2023/08/18 12:19:12 | WrapperSimpleApp Error: ... 11 more STATUS | wrapper | 2023/08/18 12:19:13 | on_exit trigger matched. Restarting the JVM. (Exit code: 1) STATUS | wrapper | 2023/08/18 12:19:19 | Launching a JVM... INFO | jvm 2 | 2023/08/18 12:19:19 | WrapperManager: Initializing...
Workaround
Option 1:
- Disable HTTP compression (gzip) on your Load Balancer/Reverse Proxy or in Bamboo's Tomcat settings if enforced (custom setting)
Option 2:
- Force your Load Balancer to intercept and respond to the following Bamboo URL with a blank page and an HTTP 200 OK success status response code:
- <Bamboo_URL>/agentServer/ – Make sure to consider the final slash "/" character
- On Nginx for example, you can the following location entry to force a blank HTTP 200 OK response:
location = /agentServer/ { default_type "text/html"; return 200 'OK'; }