Spin-transfer torque RAM (STTRAM) is an emerging non-volatile memory (NVM) technology that provides better endurance, write energy and performance than traditional NVM technologies such as Flash. In embedded application such as microcontroller SoC of Internet of Things (IoTs), embedded Flash (eFlash) is widely employed. However, eFlash is also associated with cost, poor reliability and high write energy consumption. Therefore, replacing eFlash with emerging NVMs is desirable in IoTs and have been investigated in literature. Although promising, STTRAM brings several new security and privacy challenges such as magnetic attacks that pose a significant threat to sensitive program stored in memory. In this paper, we investigate these challenges and propose a novel memory architecture for attack resilient IoT network. The information redundancy present in a homogeneous peer-to-peer connected IoT network is exploited to restore the corrupted memory of any IoT node after magnetic attack. Since restoring program memory from other IoT is associated with energy overhead, we propose to reduce the number of corrupted bits by using high retention STTRAM at the cost of one-time write energy overhead. Energy overhead for the recovery process is estimated using commercial IoT boards, showing 19.85 nJ/bit for 100 MB data transfer. Increasing the STTRAM resiliency with a thermal stability factor of 72 reduces the recovery energy overhead to 9.01 nJ/bit (54.61% improvement) for a 100 Oe magnetic attack persisting for 1 s. We further propose to reduce the transfer energy by applying error correction codes (ECC) in STTRAM, which shows 10× (10 5 ×) improvement in energy for 64 (128) bit words with 16-bit ECC.