Can you possess a creature, using the magic jar spell, if you are in an extradimensional space (assuming you can see the humanoid) in 5e

dnd-5espells

How does the spell magic jar work with an extradimensional space such as a bag of holding, handy haversack, portable hole, or the Genie Patron's Bottled Respite feature?

Assuming you are able to see out of it are you able to attempt to possess a creature? Is there anything that allows/forbids this RAW or is it up to DM interpretation? I'm asking because if you are, I think it would be a really cool thing to make your character effectively a cursed magic item.

Side note, are you able to partially have something inside one of the listed things? They don't magically teleport inside (with the exception of bottled respite), you put something in there and take it out; it transitions from the plane you are on to the extradimensional space. This is important as you need to see a creature to possess it.

Best Answer

Depends on the space

Each extradimensional space comes with their own rules, there is no unified set. The consensus is that you can cast spells out of a portable hole. To contrast, with a rope trick, you cannot cast any spells accross the entrance:

Attacks and spells can't cross through the entrance into or out of the extradimensional space

As this is not as clearly called out in all cases, those will need to be decided by your DM. The bottled respite vessel in particular does not say anything about an entrance, so it is unlikely you would be able to target anything from within, as you have no line of effect, and cannot see the target.

For your side question: again this depends on the space and in the end will be up to your DM to rule on. With rope trick, or portable hole, nothing forbids "leaning out", even though the movement rules if you use a grid do not really have a concept for this: you are in a given space, or you are not. With other spaces, like bag of holding or handy haversack, you cannot actively enter or leave, you can just be retrieved and it is described how that works in the item (note that you will suffocate and die as a breathing creature, if you stay in there longer than 10 minutes).

Practical issues with this idea

While possessing a body, you can use your action to return from the host body to the container if it is within 100 feet of you, returning the host creature's soul to its body. If the host body dies while you're in it, the creature dies, and (...) you return to the container if it is within 100 feet of you. Otherwise, you die.

The distance to an extradimensional space is undefined. In some cases like with an open portable hole, the DM may allow it to be normal distance. In most cases, it will be considered as infinite.

When the body you inhabit dies while the receptable is in the extradimensional space, you also will die, as the container is not within 100 feet of you.