Storage Fundamentals Series

🔐 A Top 1% Hands-On for Reproducing an Unauthenticated iSCSI Takeover Yourself and Confirming CHAP Authentication's Defense

Introduction

This article is part of the Top 1% Series Complete Article Guide, and the twelfth article in the Storage Fundamentals Series. You can follow along with one of the Ubuntu Server environments set up in the Hands-On Prep Manual.

Prerequisite Knowledge

Getting the Big Picture

In this hands-on, you’ll run both an iSCSI target and an initiator on the same single server, and confirm these two stages.

graph TB
    subgraph Step1["Steps 1-2: Unauthenticated State"]
        A1["Create a target<br/>(no auth configured)"]
        A2["Anyone who just knows<br/>the IQN can log in"]
        A1 --> A2
    end
    subgraph Step2["Steps 3-4: After Configuring CHAP"]
        B1["Configure CHAP<br/>on the target"]
        B2["A login gets rejected<br/>without the right username/password"]
        B1 --> B2
    end
    Step1 --> Step2

Hands-On Steps

Step 1: Create an iSCSI Target With No Authentication Configured

sudo apt install -y tgt open-iscsi
sudo dd if=/dev/zero of=/disk-iscsi.img bs=1M count=100
sudo tgtadm --lld iscsi --mode target --op new --tid 1 -T iqn.2026-11.test.example:storage.disk01
sudo tgtadm --lld iscsi --mode logicalunit --op new --tid 1 --lun 1 -b /disk-iscsi.img
sudo tgtadm --lld iscsi --mode target --op bind --tid 1 -I ALL

The -I ALL option means “allow a connection from any IP address,” and you haven’t configured any username/password authentication at all yet.

Step 2: Confirm You Can Log In From the Initiator Side, With No Authentication

sudo iscsiadm -m discovery -t sendtargets -p 127.0.0.1
sudo iscsiadm -m node -T iqn.2026-11.test.example:storage.disk01 -p 127.0.0.1 --login

Output:

Logging in to [iface: default, target: iqn.2026-11.test.example:storage.disk01, portal: 127.0.0.1,3260]
Login to [iface: default, target: iqn.2026-11.test.example:storage.disk01, portal: 127.0.0.1,3260] successful.

The login succeeded even though you never entered any username or password at all. This concretely demonstrates what you learned in How iSCSI Works: an IQN is “a name for telling who you’re talking to,” not “credentials for proving who you actually are.” This is a state where anyone who can reach the same network and knows the target’s IQN can read and write that storage’s contents.

Why an IQN Alone Never Proves Identity

As you learned in How iSCSI Works, an IQN is an identifier that keeps uniquely identifying who you’re talking to, regardless of IP address changes. But being an identifier and being a credential are entirely different properties. An IQN is close to public information — anyone who sniffs the network traffic can learn it. Unlike a password, it’s not a secret known only to the real owner, so the mere fact of knowing an IQN proves nothing about whether the other party is actually a legitimate initiator.

Step 3: Log Out and Configure CHAP Authentication

sudo iscsiadm -m node -T iqn.2026-11.test.example:storage.disk01 -p 127.0.0.1 --logout
sudo tgtadm --lld iscsi --mode account --op new --user tgtuser --password tgtpass12345
sudo tgtadm --lld iscsi --mode target --op bind --tid 1 -I ALL
sudo tgtadm --lld iscsi --mode account --op bind --tid 1 --user tgtuser

Now the target side only accepts, as a legitimate connection, “whoever presents the name tgtuser along with its matching password.” This is “CHAP” (Challenge-Handshake Authentication Protocol) authentication.

Step 4: Confirm a Login With No Credentials Gets Rejected

sudo iscsiadm -m node -T iqn.2026-11.test.example:storage.disk01 -p 127.0.0.1 --login

Output:

iscsiadm: Could not login to [iface: default, target: iqn.2026-11.test.example:storage.disk01, portal: 127.0.0.1,3260].
iscsiadm: initiator reported error (24 - iSCSI login failed due to authorization failure)

Unlike before, the login got rejected. Now configure the correct username and password on the initiator side, and log in again.

sudo iscsiadm -m node -T iqn.2026-11.test.example:storage.disk01 -p 127.0.0.1 \
  -o update -n node.session.auth.authmethod -v CHAP
sudo iscsiadm -m node -T iqn.2026-11.test.example:storage.disk01 -p 127.0.0.1 \
  -o update -n node.session.auth.username -v tgtuser
sudo iscsiadm -m node -T iqn.2026-11.test.example:storage.disk01 -p 127.0.0.1 \
  -o update -n node.session.auth.password -v tgtpass12345
sudo iscsiadm -m node -T iqn.2026-11.test.example:storage.disk01 -p 127.0.0.1 --login

Output:

Login to [iface: default, target: iqn.2026-11.test.example:storage.disk01, portal: 127.0.0.1,3260] successful.

The login only succeeded once you presented the correct username and password. You’ve concretely confirmed that configuring CHAP authentication closes off the dangerous state from Step 2 — “anyone who just knows the IQN can log in.”

What a Pro Sees Here (Top 1% Understanding)

Carry the Premise That “a Default Configuration Is Never Guaranteed to Be Safe”

The biggest lesson from this hands-on is that the initial state right after creating a target with tgtadm has zero authentication defense active at all. A great many storage and network devices’ default configurations prioritize “getting it working” first, with the expectation that the user will additionally configure “getting it working safely” themselves. This shares the same underlying idea as an old protocol like SMB1 now getting disabled by default. A top-1% engineer needs the habit of explicitly checking, every time, “is it actually fine to use the default configuration as-is,” whenever introducing a new device or service.

Common Misconceptions and Pitfalls

Troubleshooting Perspective

  1. An existing initiator can no longer log in after configuring CHAP authentication: Check whether the initiator side’s configuration reflects the correct username and password.
  2. An unintended host is allowed to connect to the iSCSI target: Check whether a setting allowing every IP address, like tgtadm --mode target --op bind -I ALL, has been left in place.
  3. You want to change the CHAP authentication password: You need to update both the target side’s account configuration and the initiator side, simultaneously.

Summary

Takeaways to Apply Today

  1. When building a new iSCSI target, always include configuring CHAP authentication as part of your initial build procedure.
  2. When introducing storage or network equipment, explicitly check every time whether using the default configuration as-is is actually safe.

References

Comments

Feel free to leave thoughts, questions, or corrections below (sign in with a GitHub account to comment or react).