Execution Monitoring of Security-Critical Programs in Distributed Systems: A Specification-Based Approach