Strange shell behavior in nested LXD

Seeing some strange behavior when using a nested LXD. Wonder if its a bug or I am overlooking something obvious. When provisioning containers I often make use of shell HEREDOCs such as:

lxc exec test -- bash <<END
# do stuff
END

Some of those scripts now need to run inside a nested LXD, however the HEREDOC fails within the inner container. Seems bash runs but stdin appears to be ignored. For example using this as my example script test-heredoc.sh :

#!/bin/bash

CONTAINER=test

echo "Test HEREDOC"
lxc exec $CONTAINER -- bash <<END
uname -r
END

echo "Test PIPE"
echo "uname -r" | lxc exec $CONTAINER -- bash

On host server I create outer container and run script. The output is correct:

lxc launch  ubuntu:focal test -c security.nesting=true
./test-heredoc.sh
Test HEREDOC
5.4.0-81-lowlatency
Test PIPE
5.4.0-81-lowlatency

Then create another container within the first instance. The HEREDOC fails but normal PIPE works:

Test HEREDOC
Test PIPE
5.4.0-81-lowlatency

If the outer instance is a VM everything works as expected. Any ideas ?

host, outer and inner are running Ubuntu Focal
LXD version is 4.0.7