The embassy is not technically the sovereign territory of the sending country; it remains the sovereign territory of the receiving country, although it does enjoy special protections from interference from the receiving country.
The sending country could do anything they like to you once you enter the embassy - including hanging you for treason - as long as they keep you in the embassy. This may be illegal according to the receiving country's laws - hence illegal in actual fact, since the receiving country's laws apply in theory - but the receiving country would be legally prevented from interfering with the sending country's actions if they take place in the embassy.
What if the sending country does something the receiving country disagrees with? Well, that's sort of where the law stops and politics begins. The countries can negotiate, diplomats can be expelled and embassies closed, sanctions can be imposed and wars declared. This category of thing also includes the receiving country reneging on its agreement and violating the protections of the embassy and/or its diplomats, which would create an international incident and may lead to some or all of the above.
- The Syrian embassy would be violating the law of the receiving country to punish you in such a way as to break the laws of the receiving country for having broken Syrian law while you are visiting an embassy abroad
- The receiving country would be violating its diplomatic and political agreements not to interfere in the embassy if it decided to interfere with the embassy if the embassy chose to broke the law of the receiving country by punishing you
- If the sending country break's the receiving country's laws in a way the receiving country cares about, or if the receiving country violates the immunity of the embassy in a way the sending country cares about, there will be an international incident which will be resolved by political processes. Odds are if it gets to this stage you're not in great shape.