Although mobile agents are a promising technology, the large-scale deployment of agents and the existence of hosts running agencies will not happen until proper security mechanisms are well understood and implemented. When considering global open environments as the Internet, mobile agents can be the victims of attacks by malicious hosts. In this paper, we present a security framework that protects agents from interference of untrusted and potentially malicious hosts. The framework can be used to enable technologies as electronic commerce, using the mobile agent paradigm in a secure and trustful way.