Raspberry Pi is a wonderful, low cost, device that's perfect for security and home automation projects. Unfortunately, Raspbian, the officially supported operating system for the Raspberry Pi, places an emphasis on usability and approachability over security. This certainly doesn't mean, however, that Raspbian is insecure. It just means that you're going to have to take some extra time and make some extra effort to secure your Raspberry pi device.
Designing a secure IoT solution depends on a number of security considerations. One of the most important consideration is the use of a secure IoT framework for building your ecosystem. Using a secure framework ensures that developers don't overlook security considerations and allows for rapid application development. Ideally a framework contains security components baked into the framework in such a way as to provide security by default that developers don't have to think about. This frees developers and architects to focus on features and capabilities without burdening their development efforts with security considerations (or mistakes).