# System keys are accessible by default with Go bindings

**URL:** <https://forums.foundationdb.org/t/system-keys-are-accessible-by-default-with-go-bindings/2827>\
**Category:** Using FoundationDB\
**Tags:** bindings\
**Created:** [July 30, 2021, 5:07am UTC](https://forums.foundationdb.org/t/system-keys-are-accessible-by-default-with-go-bindings/2827 "2021-07-30T05:07:14Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![falsandtru](https://sea1.discourse-cdn.com/foundationdb/user_avatar/forums.foundationdb.org/falsandtru/32/546_2.png) [@falsandtru](https://forums.foundationdb.org/u/falsandtru)\
**Post date:** [July 30, 2021, 5:07am UTC](https://forums.foundationdb.org/t/system-keys-are-accessible-by-default-with-go-bindings/2827/1 "2021-07-30T05:07:14Z")

</div>

Looks like a dangerous bug.

[github.com/apple/foundationdb/bindings/go](http://github.com/apple/foundationdb/bindings/go) v0.0.0-20210729182842-f6596a740b02

```go
// Can access without tx.Options().SetAccessSystemKeys()
tx.Get(fdb.Key("\xFF\xFF/cluster_file_path")).MustGet()

```

Another, a tuple element (of subspaces) starting with `\xFF` may also conflict with a system key? So shouldn’t I accept a tuple element starting with `\xFF`?

---

<div class="post-metadata">

**Author:** ![andrew.noyes](https://sea1.discourse-cdn.com/foundationdb/user_avatar/forums.foundationdb.org/andrew.noyes/32/443_2.png) [@andrew.noyes](https://forums.foundationdb.org/u/andrew.noyes)\
**Post date:** [July 30, 2021, 5:39am UTC](https://forums.foundationdb.org/t/system-keys-are-accessible-by-default-with-go-bindings/2827/2 "2021-07-30T05:39:46Z")

</div>

`\xff\xff/cluster_file_path` is actually not a system key, but instead a [special key](https://apple.github.io/foundationdb/developer-guide.html#special-keys). Being able to access it without setting the “access system keys” transaction option is intentional. Part of the [design of the tuple layer](https://github.com/apple/foundationdb/blob/master/design/tuple.md) is that serialized keys should never start with `\xff`. Do you have an example of a tuple that starts with `\xff` when serialized? If so please share.

---

<div class="post-metadata">

**Author:** ![falsandtru](https://sea1.discourse-cdn.com/foundationdb/user_avatar/forums.foundationdb.org/falsandtru/32/546_2.png) [@falsandtru](https://forums.foundationdb.org/u/falsandtru)\
**Post date:** [July 30, 2021, 6:04am UTC](https://forums.foundationdb.org/t/system-keys-are-accessible-by-default-with-go-bindings/2827/3 "2021-07-30T06:04:43Z")

</div>

> [@andrew.noyes](#):
>
> `\xff\xff/cluster_file_path` is actually not a system key, but instead a [special key](https://apple.github.io/foundationdb/developer-guide.html#special-keys).

I see. However, anyway it looks dangerous.

> [@andrew.noyes](#):
>
> Part of the [design of the tuple layer](https://github.com/apple/foundationdb/blob/master/design/tuple.md) is that serialized keys should never start with `\xff` . Do you have an example of a tuple that starts with `\xff` when serialized? If so please share.

I’ll use subspaces to escape the leading `\xFF`. Thanks!

---

<div class="post-metadata">

**Author:** ![andrew.noyes](https://sea1.discourse-cdn.com/foundationdb/user_avatar/forums.foundationdb.org/andrew.noyes/32/443_2.png) [@andrew.noyes](https://forums.foundationdb.org/u/andrew.noyes)\
**Post date:** [July 30, 2021, 6:09am UTC](https://forums.foundationdb.org/t/system-keys-are-accessible-by-default-with-go-bindings/2827/4 "2021-07-30T06:09:54Z")

</div>

> [@falsandtru](#):
>
> I’ll use subspaces to escape the leading `\xFF`

What I’m saying is there won’t ever be a leading \xff in the serialized key.

```auto
>>> fdb.tuple.pack((b'\xff',))
'\x01\xff\x00'

```

---

<div class="post-metadata">

**Author:** ![falsandtru](https://sea1.discourse-cdn.com/foundationdb/user_avatar/forums.foundationdb.org/falsandtru/32/546_2.png) [@falsandtru](https://forums.foundationdb.org/u/falsandtru)\
**Post date:** [July 30, 2021, 6:15am UTC](https://forums.foundationdb.org/t/system-keys-are-accessible-by-default-with-go-bindings/2827/5 "2021-07-30T06:15:56Z")

</div>

So `subspace.Sub("\xFF...")` is unsafe?

---

<div class="post-metadata">

**Author:** ![andrew.noyes](https://sea1.discourse-cdn.com/foundationdb/user_avatar/forums.foundationdb.org/andrew.noyes/32/443_2.png) [@andrew.noyes](https://forums.foundationdb.org/u/andrew.noyes)\
**Post date:** [July 30, 2021, 6:23am UTC](https://forums.foundationdb.org/t/system-keys-are-accessible-by-default-with-go-bindings/2827/6 "2021-07-30T06:23:43Z")

</div>

The python binding (and probably all the bindings) use the tuple layer to encode the key prefix they use. The python binding provides a backdoor you can use to set the raw prefix directly, and using a prefix starting with `\xff` would be unsafe.

```auto
>>> fdb.Subspace(('foo',))
Subspace(rawPrefix='\x01foo\x00')

```

---

<div class="post-metadata">

**Author:** ![falsandtru](https://sea1.discourse-cdn.com/foundationdb/user_avatar/forums.foundationdb.org/falsandtru/32/546_2.png) [@falsandtru](https://forums.foundationdb.org/u/falsandtru)\
**Post date:** [July 30, 2021, 6:36am UTC](https://forums.foundationdb.org/t/system-keys-are-accessible-by-default-with-go-bindings/2827/7 "2021-07-30T06:36:46Z")

</div>

I see, I don’t use the raw prefix option. Thanks.
