For cybersecurity reasons, I want to make sure a device connected to my CAN bus is read-only.
What's the state-of-the-art way of doing this?
My naive plan was to simply use two diodes.
For cybersecurity reasons, I want to make sure a device connected to my CAN bus is read-only.
What's the state-of-the-art way of doing this?
My naive plan was to simply use two diodes.
The idea is right, but a diode is the wrong way to do it. Use a buffer IC instead. [EDIT: Actually, you can just use diodes for receive-only operation, as per the setup in TonyM's answer. I had forgotten that CANBus receivers don't need to be able to detect a hi-Z bus state.]
You could also look into using a CANBus firewall device, which allows you to specify filters for the types of frames that can go in each direction. These are becoming more common in connected vehicles due to the increased risks involved. Modern vehicles often include these in the wiring loom at specific junctures, e.g. the interconnect between the head unit and the ECU.
You can use your two diodes then series resistors. These ensure that a fault in any circuit or IC, including your suggested buffer IC, cannot clamp either CAN bus line low.
You can go further and use two resistors in series for increased reliability. A single component failure cannot then allow the MCU to load the bus through a fault in bad software.

simulate this circuit – Schematic created using CircuitLab
Every CAN transceiver has CANTX and CANRX pins. Simply don't connect CANTX to your controller or MCU CANTX pin and it won't ever be able to transmit but reception will work just fine.
Maybe put a 0R resistor footprint in case you do want to transmit one day.
There are capacitive coupled CANbus sniffers, they can listen to a CAN bus, but not transmit data on it.