
Python script to detect CVE-2026-24061 telnetd vulnerability via NEW-ENVIRON injection, providing risk assessment and mitigation guidance.
A Python security testing tool to detect vulnerability to environment variable injection in telnetd servers via the NEW-ENVIRON telnet option.
This script tests telnetd servers for CVE-2026-24061, a vulnerability that allows attackers to inject environment variables through the NEW-ENVIRON telnet option. If a server improperly handles these environment variables, it may be vulnerable to command injection or authentication bypass attacks.
The script provides detailed, color-coded output with step-by-step progress, comprehensive error handling, and a final summary that includes the test result, risk assessment, and impact analysis.
CVE-2026-24061 is a security vulnerability in telnetd servers that improperly handle environment variables sent via the NEW-ENVIRON telnet option (RFC 1572).
The vulnerability occurs when telnetd servers:
The NEW-ENVIRON option (RFC 1572) allows telnet clients to send environment variables to the server. A vulnerable server may accept and process these variables without sanitization, potentially allowing an attacker to inject malicious values that could lead to command execution or authentication bypass.
No installation required. The script is standalone and uses only Python standard library modules.
Linux (Ubuntu/Debian):
sudo apt-get update
sudo apt-get install python3
macOS (using Homebrew):
# Install Homebrew if not already installed
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Install Python 3
brew install python3
# Verify installation
python3 --version
Windows:
python --version
python --version
Linux/macOS:
./telnetd_CVE‑2026‑24061_test.py <host> [port]
Windows (Command Prompt):
python telnetd_CVE‑2026‑24061_test.py <host> [port]
Windows (PowerShell):
python telnetd_CVE‑2026‑24061_test.py <host> [port]
Linux/macOS:
# Test default telnet port (23)
./telnetd_CVE‑2026‑24061_test.py 10.0.2.134
# Test custom port
./telnetd_CVE‑2026‑24061_test.py 10.0.2.134 2323
# Make script executable (if needed)
chmod +x telnetd_CVE‑2026‑24061_test.py
# Or run directly with python3
python3 telnetd_CVE‑2026‑24061_test.py 10.0.2.134 2323
Windows (Command Prompt):
REM Test default telnet port (23)
python telnetd_CVE‑2026‑24061_test.py 10.0.2.134
REM Test custom port
python telnetd_CVE‑2026‑24061_test.py 10.0.2.134 2323
Windows (PowerShell):
# Test default telnet port (23)
python telnetd_CVE‑2026‑24061_test.py 10.0.2.134
# Test custom port
python telnetd_CVE‑2026‑24061_test.py 10.0.2.134 2323
macOS (Homebrew Python):
# If using Homebrew-installed Python, use python3 explicitly
python3 telnetd_CVE‑2026‑24061_test.py 10.0.2.134
# Or make executable and run directly
chmod +x telnetd_CVE‑2026‑24061_test.py
./telnetd_CVE‑2026‑24061_test.py 10.0.2.134 2323
NO_COLOR environment variable is setThe script provides four possible outcomes:
[-] NEW-ENVIRON not accepted
[RESULT] NOT IMPACTED
Meaning: The server does not support or accept the NEW-ENVIRON option. The server is not vulnerable to this specific attack vector.
Summary Information:
Action Required:
[!] ENV accepted by server
[RESULT] LIKELY IMPACTED (CVE-2026-24061)
Meaning: The server accepted the NEW-ENVIRON option and appears to have processed the injected environment variable. The server is likely vulnerable to CVE-2026-24061.
Summary Information:
Action Required:
[+] No response to ENV injection
[RESULT] INCONCLUSIVE
Meaning: The server accepted NEW-ENVIRON but did not provide a clear response. Manual verification is recommended.
Summary Information:
Action Required:
[RESULT] TEST FAILED - Communication Error
Meaning: The test could not be completed due to a communication error.
Summary Information:
Action Required:
IAC DO NEW_ENVIRON to request NEW-ENVIRON optionIAC WILL NEW_ENVIRON)USER=-f root environment variable via NEW-ENVIRON-f flag is a common login bypass techniqueThe script uses standard telnet protocol byte values:
IAC (255): Interpret As CommandDO (253): Request option enablementWILL (251): Agree to enable optionSB (250): Subnegotiation BeginSE (240): Subnegotiation EndNEW_ENVIRON (39): NEW-ENVIRON option number (RFC 1572)The injection payload follows RFC 1572 format:
IAC SB NEW_ENVIRON IS VAR USER <0x01>-f root IAC SE
Where:
IAC SB: Start subnegotiationNEW_ENVIRON: Option identifierIS: Information SubnegotiationVAR: Variable type indicatorUSER: Environment variable name0x01: VALUE byte-f root: Injected valueIAC SE: End subnegotiationThe script includes comprehensive error handling for:
All errors are reported with clear, color-coded, user-friendly messages that include:
⚠️ Important: This script is for authorized security testing only.
If a server is found to be vulnerable:
Immediate Actions:
Configuration Changes:
Long-term Solutions:
The script automatically detects terminal color support and uses ANSI colors for better readability:
NO_COLOR=1 environment variableFORCE_COLOR=1 environment variableExample:
# Disable colors
NO_COLOR=1 ./telnetd_CVE‑2026‑24061_test.py 10.0.2.134
# Force colors (useful for some terminals)
FORCE_COLOR=1 ./telnetd_CVE‑2026‑24061_test.py 10.0.2.134
This script is provided as-is for security testing purposes. Use at your own risk.
NO WARRANTY
THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
LIMITATION OF LIABILITY
THE AUTHORS, CONTRIBUTORS, AND DISTRIBUTORS OF THIS SOFTWARE SHALL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
USE AT YOUR OWN RISK
Improvements and bug reports are welcome. Please ensure any modifications maintain the script's security testing purpose and ethical use guidelines.