Here's a possibly-wrong approach ...
Center a "short" cylinder at the cuboid's center, oriented along a diagonal. Elongate the cylinder ---in each direction--- until it collides with a face, say the "top" (and, at the other end, the "bottom"). Letting the cylinder scrape against the top (and bottom) face(s), continue elongating the cylinder ---such that the projection of its axis into the top face coincides with the face's diagonal--- until it collides with a second (pair of) face(s). Finally, letting the cylinder scrape those faces, elongate in the only dimension allowable until it collides with the final (pair of) face(s).
Symbolically ...
Let the cuboid have dimensions $2a$, $2b$, $2c$; center it at the origin, and let its edges be axis-aligned. Let the cylinder have radius $s$. (I use "$r$" below for a different parameter.)
Taking $P = p \; ( a, b, c )$ to be the center of one end of the "short" cylinder, we elongate the cylinder (that is, we increase $p$) until it collides with the walls $x=\pm a$; this happens when
$P_x + s \frac{P_x}{|P|} = a \qquad (1)$
Let $p_\star$ be the value of $p$ solving $(1)$.
Now, let $Q := p_\star \; ( a, b, c ) + q \; ( 0, b, c )$ take over as the center of the end of the cylinder; we elongate until the cylinder hits the walls $y=\pm b$:
$Q_y + s \frac{Q_y}{|Q|} = b \qquad (2)$
Writing $q_\star$ for the appropriate value of $q$ solving $(2)$, we finish with cylindrical endpoint $R := p_\star \; ( a, b, c ) + q_\star\; ( 0, b, c ) + r ( 0, 0, c )$ until
$R_z + s \frac{R_z}{|R|} = c \qquad (3)$
when $r = r_\star$. Then
$\ell = 2|R| = 2\sqrt{\; p_\star^2 \; a^2 + \left( p_\star + q_\star \right)^2 \; b^2 + \left( p_\star + q_\star + r_\star \right)^2 \; c^2 \; }$
may (or may not) be the length of the longest cylinder in the cuboid. At least, it should be a "local maximum".
As for solving $(1)$, $(2)$, $(3)$ ...
For $(1)$, defining $d := \sqrt{a^2+b^2+c^2}$, we have
$p a + s \frac{p a}{p d} = a \qquad \to \qquad p_\star = 1 - \frac{s}{d}$
For $(2)$, we have
$(p_\star+q) b + \frac{s(p_\star + q )b}{\sqrt{p_\star^2 a^2 + (p_\star + q )^2(b^2+c^2)}} = b$ $\to \qquad s(p_\star + q ) = \left(1-p_\star-q\right)\;\sqrt{p_\star^2 a^2 + (p_\star + q )^2(b^2+c^2)}$ $\to \qquad s^2 (p_\star + q )^2 = \left(1-p_\star-q\right)^2\;\left( p_\star^2 a^2 + (p_\star + q )^2(b^2+c^2) \right)$
which makes $q_\star$ the root of a quartic polynomial. The same is true for $r_\star$. I'll leave the sorting-out of those roots to the reader.