<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>182972</bug_id>
          
          <creation_ts>2018-02-20 07:16:08 -0800</creation_ts>
          <short_desc>WebCrypto keys break autoincrementing primary keys of IndexedDB</short_desc>
          <delta_ts>2019-10-25 03:21:16 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>WebCore Misc.</component>
          <version>Safari Technology Preview</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=177350</see_also>
    
    <see_also>https://bugs.webkit.org/show_bug.cgi?id=160306</see_also>
    
    <see_also>https://bugs.webkit.org/show_bug.cgi?id=133122</see_also>
          <bug_file_loc>https://gist.github.com/sechel/415c34b9bf80f3adeba52856d2377393</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          <blocked>133122</blocked>
    
    <blocked>160306</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Stefan Sechelmann">stefan</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>beidson</cc>
    
    <cc>jiewen_tan</cc>
    
    <cc>mcatanzaro</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>zan</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1400756</commentid>
    <comment_count>0</comment_count>
    <who name="Stefan Sechelmann">stefan</who>
    <bug_when>2018-02-20 07:16:08 -0800</bug_when>
    <thetext>When storing an object that contains a WebCrypto CryptoKey to an IDB object store with auto incrementing primary key we get the following error:
Error: Unable to inject record key into record value

See also https://gist.github.com/sechel/415c34b9bf80f3adeba52856d2377393</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1400859</commentid>
    <comment_count>1</comment_count>
    <who name="Jiewen Tan">jiewen_tan</who>
    <bug_when>2018-02-20 11:53:42 -0800</bug_when>
    <thetext>I tried the test case in Safari. It doesn&apos;t reproduce the bug. A very primitive suggestion here is to see if SerializedCryptoKeyWrap.h has caused some troubles for GTK+.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1400862</commentid>
    <comment_count>2</comment_count>
    <who name="Jiewen Tan">jiewen_tan</who>
    <bug_when>2018-02-20 12:00:42 -0800</bug_when>
    <thetext>I remember I told Zan not to wrap/unwrap Crypto Keys for GTK+, so it shouldn&apos;t cause any troubles for you.

Wrapping crypto keys when storing them into IndexedDB is a legacy behavior to protect them in order to address early limitations of the spec. However, since we have existing clients that have already stored wrapped keys in IndexedDb, Apple ports couldn&apos;t get rid of it at this moment.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1400880</commentid>
    <comment_count>3</comment_count>
    <who name="Zan Dobersek">zan</who>
    <bug_when>2018-02-20 13:07:04 -0800</bug_when>
    <thetext>(In reply to Jiewen Tan from comment #2)
&gt; I remember I told Zan not to wrap/unwrap Crypto Keys for GTK+, so it
&gt; shouldn&apos;t cause any troubles for you.
&gt; 
&gt; Wrapping crypto keys when storing them into IndexedDB is a legacy behavior
&gt; to protect them in order to address early limitations of the spec. However,
&gt; since we have existing clients that have already stored wrapped keys in
&gt; IndexedDb, Apple ports couldn&apos;t get rid of it at this moment.

Keys are still not wrapped for the GTK+ port, as recommended.

At least per this bug report, issue is observed with the Safari Tech Preview. OTOH the test case passes on GTK+/WPE as well, meaning that the issue appears to be present (as otherwise the test case would fail).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1400891</commentid>
    <comment_count>4</comment_count>
    <who name="Zan Dobersek">zan</who>
    <bug_when>2018-02-20 13:33:13 -0800</bug_when>
    <thetext>Failure occurs during deserialization because UniqueIDBDatabase provides an ExecState from which a usable ScriptExecutionContext cannot be retrieved. That&apos;s currently necessary in order to pipe the serialization and deserialization operations all the way up to the WebChromeClient in UIProcess.

https://trac.webkit.org/browser/webkit/trunk/Source/WebCore/bindings/js/SerializedScriptValue.cpp#L477
https://trac.webkit.org/browser/webkit/trunk/Source/WebCore/bindings/js/ScriptState.cpp#L65</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1400900</commentid>
    <comment_count>5</comment_count>
    <who name="Stefan Sechelmann">stefan</who>
    <bug_when>2018-02-20 14:02:57 -0800</bug_when>
    <thetext>&gt; OTOH the test case passes on GTK+/WPE as well, meaning that the issue appears to be present (as otherwise the test case would fail).
Thats right, sorry for causing confusion. The test case is written canary style meaning it will fail if the issue has been resolved.

BTW, this bug seems to be related as it also involves creating indices with WebCrypto keys present:
https://bugs.webkit.org/show_bug.cgi?id=177350</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1459723</commentid>
    <comment_count>6</comment_count>
    <who name="Stefan Sechelmann">stefan</who>
    <bug_when>2018-09-14 05:24:28 -0700</bug_when>
    <thetext>Anything new in the meantime? I will now perform another attempt to port out web application to Safari. Its pretty frustrating that I need so many Workarounds just due to WebCrypto.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1583746</commentid>
    <comment_count>7</comment_count>
    <who name="Stefan Sechelmann">stefan</who>
    <bug_when>2019-10-25 03:20:35 -0700</bug_when>
    <thetext>This has been fixed in Safari 13.x.x.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1583747</commentid>
    <comment_count>8</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2019-10-25 03:21:16 -0700</bug_when>
    <thetext>&lt;rdar://problem/56613473&gt;</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>