upvote
There is a setting as of iOS 26 under "Privacy & Security > Wired Accessories" in which you can make data connections always prompt for access. Not that there haven't been bypasses for this before, but perhaps still of interest to you.
reply
GrapheneOS does this by default - only power delivery when locked. Also it's a hardware block, not software. Seems to be completely immune to these USB exploit tools.
reply
It also has various options to adjust the behaviour, from no blocks at all, to not even being able to charge the phone (or use the phone to charge something else) -- even when unlocked. Changing the mode of operation requires the device PIN, just as changing the device PIN does.

Note that it behaves subtly differently to how you described in case it was connected to something before being locked. In that case data access will remain -- even though the phone is now locked -- until the device is disconnected.

reply
> I would totally enable an "enhanced protection for external accessories" mode.

Anyone can do this for over a decade now, and it's fairly straightforward:

- 2014: https://www.zdziarski.com/blog/?p=2589

- recent: https://reincubate.com/support/how-to/pair-lock-supervise-ip...

This goes beyond the "wired accessories" toggle.

reply
It isn’t. Settings > Privacy & Security > Wired Accessories

Set to ask for new accessories or always ask.

reply
I have to warn you, it does get annoying when you plug in your power-only cable and it still nags you with the question. But it does work as intended!
reply
You might want to check that charger. I have the same option set to ask every time and it never appears for chargers.
reply
> it has a noticeable impact on device functionality.

The lack of optional granularity on security settings is super frustrating because it leads to many users just opting out of any heightened security.

reply
Computer security is generally inversely proportional to convenience. Best opsec is generally to have multiple devices.
reply
> I never attach my iPhone to anything that's not a power source.

It's "attached" to the wifi and to the cell network. Pretty much the same thing.

reply