# Is this secure? Concept for private info in replies

**URL:** <https://meta.discourse.org/t/is-this-secure-concept-for-private-info-in-replies/64385>\
**Category:** Development\
**Created:** [12 ביוני,‏ 2017,‏ 10:06pm UTC](https://meta.discourse.org/t/is-this-secure-concept-for-private-info-in-replies/64385 "2017-06-12T22:06:41Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![rohmann](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rohmann/32/120852_2.png) [@rohmann](https://meta.discourse.org/u/rohmann)\
**Post date:** [12 ביוני,‏ 2017,‏ 10:06pm UTC](https://meta.discourse.org/t/is-this-secure-concept-for-private-info-in-replies/64385/1 "2017-06-12T22:06:41Z")

</div>

I really need a way for users to add sensitive data to a post without using private messages. I have this in a plugin:

```ruby
require_dependency "plugin/filter"

  Plugin::Filter.register(:after_post_cook) do |post, cooked|
    index=0
    cooked.gsub(/\[secret\].*?\[\/secret\]/) { |a| index+=1; "<div class="secret-info" data-secret-post-id=\"#{post.id}\" data-secret-post-index=\"#{index}\">#{I18n.t('secret_replies.cooked_message')}</div>" }
  end

```

Effectively, it takes this content:

```plaintext
Anyone can see this.
[secret]but not this[/secret]
[secret]and DEFINITELY not this[/secret]

```

and cooks down to:

```html
<p>Anyone can see this.</p>
<div class="secret-info" data-secret-post-id="42" data-secret-post-index="1">This content has been marked as secret. It is visible to staff and the original poster.</div>
<div class="secret-info" data-secret-post-id="42" data-secret-post-index="2">This content has been marked as secret. It is visible to staff and the original poster.</div>

```

Assuming this is safe to do, the rest of the plugin can be built around this concept. For example, there can be a protected endpoint for retrieving the raw content, and client modifications to add it back to the cooked content.

I do understand that if a user is given the ability to edit a post they will get raw content. I’m ok with this since those users are already staff, or are otherwise trustworthy with these secrets.

Main question: Is there any unguarded context where Discourse outputs raw post content instead of cooked content?

Any other security concerns? Thanks!

---

_[View the full topic](https://meta.discourse.org/t/is-this-secure-concept-for-private-info-in-replies/64385)._
