Pervasive user mobility, wireless connectivity and the widespread diffusion of portable devices raise new challenges for ubiquitous service provisioning. An emerging architecture solution in the wireless Internet is based on mobile proxies (implemented as mobile agentbased middleware components) over the fixed network that follow the movements and act on behalf of the limited wireless clients. It is crucial that mobile proxies have full visibility of their context, i.e., the set of available and relevant resources, depending on access control rules, client location, user preferences, privacy requirements, terminal characteristics, and current state of hosting environments. The paper presents the design and implementation of a context-centric security middleware, called UbiCOSM, for MA-based service provisioning in pervasive computing. UbiCOSM dynamically determines the contexts of mobile proxies, and effectively rules the access to them, by taking into account different types of metad...